【发布时间】:2011-03-27 09:59:35
【问题描述】:
假设我有一个表和一个索引
original simple table A
------------------------
rowid | id name
123 | 1 A
124 | 4 G
125 | 2 R
126 | 3 P
index on A.id
-------------
id rowid
1 123
2 125
3 126
4 124
此时,我执行这个 DML 语句
UPDATE A SET id = 5 WHERE id = 4
当这个语句被执行时究竟会发生什么?
一)
BEGIN
go to index
search for `id == 4` (B tree index generally)
find that `rowid = 124`
go to that location
update id in the table
come back (? I am not sure)
update the index
END
b)
BEGIN
go to index
search for `id == 4` (B tree index generally)
update the id value in index
find that `rowid = 124`
go to that location
update id in the table
END
c) 完全发生了其他事情
由于这可能取决于数据库本身,它在 Oracle 中是如何发生的?
【问题讨论】:
-
我猜实现会有所不同,其中许多将默认为 c) 而不是简单地插入 a) 或 b)...
-
@Henk:不。我只是想了解它是如何工作的。这是我编造的一个场景。
-
好的。只是看起来有点做作。
标签: database oracle algorithm indexing