Oracle的索引是以平衡树的方式组织存储的:保存的是索引列的值,以及该行的rowid的一部分(文件号,块号,行号)
下面我们通过例子来了解一下:
1,create table test(id int,name varchar2(20))
insert into test values(1,'A');
insert into test values(2,'B');
begin
for i in 3..2000 loop
insert into test values(i,'t'||i);
end loop;
end;
2,create index idx_test on test(id)
3,得到这个index的object_id:
SQL> select object_id from dba_objects where object_name='IDX_TEST';
OBJECT_ID
----------
74560
4,将索引dump到trace文件中
alter session set events 'immediate trace name treedump level 74560';
看到结果:有两层,5个叶子节点
----- begin tree dump
branch: 0x1000c93 16780435 (0: nrow: 5, level: 1)<