索引ROWID转换函数

SQL> create table t as select * from dba_objects;

表已创建。

SQL> create index t_idx on t(object_name);

索引已创建。

SQL> alter system checkpoint;

系统已更改。

SQL> select header_file,header_block from dba_segments where segment_name='T_IDX';

HEADER_FILE HEADER_BLOCK                                                        
----------- ------------                                                        
          4         1154                                                        

SQL> alter system dump datafile 4 block 1156;

系统已更改。

row#0[7996] flag: ------, lock: 0, len=40
col 0; len 30; (30):
2f 31 30 30 30 33 32 33 64 5f 44 65 6c 65 67 61 74 65 49 6e 76 6f 63 61 74
69 6f 6e 48 61
col 1; len 6; (6):  01 00 02 66 00 1b


这个是索引中存储的ROWID信息,但是,具体指向的是哪里呢?
实际上rowid包含以下内容:32位object_id,10位file#,22位block#,16位row#
对于普通索引而言,没有32位的object_id

我们只需要将"01 00 02 66 00 1b”转换为2进制,截取相应的长度即可找出具体的指向。


SQL> select idx_rowid('01 00 02 66 00 1b') from dual;

IDX_ROWID('01000266001B')                                                      
--------------------------------------------------------------------------------
File# = 4, Block# = 614, Row# = 27                                             

SQL> alter system dump datafile 4 block 614;

系统已更改。

tab 0, row 27, @0x1421
tl: 107 fb: --H-FL-- lb: 0x0  cc: 14
col  0: [ 3]  53 59 53
col  1: [30]
2f 31 30 30 30 33 32 33 64 5f 44 65 6c 65 67 61 74 65 49 6e 76 6f 63 61 74
69 6f 6e 48 61
col  2: *NULL*
col  3: [ 4]  c3 04 29 2b
col  4: *NULL*
col  5: [10]  4a 41 56 41 20 43 4c 41 53 53
col  6: [ 7]  78 6e 05 19 0e 0c 1a
col  7: [ 7]  78 6e 05 19 0e 0c 1a
col  8: [19]  32 30 31 30 2d 30 35 2d 32 35 3a 31 33 3a 31 31 3a 32 35
col  9: [ 5]  56 41 4c 49 44
col 10: [ 1]  4e
col 11: [ 1]  4e
col 12: [ 1]  4e
col 13: [ 2]  c1 02
tab 0, row 28, @0x13b6


SQL> select idx_rowid('01 00 02 66 00 1b') from dual;

IDX_ROWID('01000266001B')                                                      
--------------------------------------------------------------------------------
File# = 4, Block# = 614, Row# = 27                                             

SQL> alter system dump datafile 4 block 614;

系统已更改。

tab 0, row 27, @0x1421
tl: 107 fb: --H-FL-- lb: 0x0  cc: 14
col  0: [ 3]  53 59 53
col  1: [30]
2f 31 30 30 30 33 32 33 64 5f 44 65 6c 65 67 61 74 65 49 6e 76 6f 63 61 74
69 6f 6e 48 61
col  2: *NULL*
col  3: [ 4]  c3 04 29 2b
col  4: *NULL*
col  5: [10]  4a 41 56 41 20 43 4c 41 53 53
col  6: [ 7]  78 6e 05 19 0e 0c 1a
col  7: [ 7]  78 6e 05 19 0e 0c 1a
col  8: [19]  32 30 31 30 2d 30 35 2d 32 35 3a 31 33 3a 31 31 3a 32 35
col  9: [ 5]  56 41 4c 49 44
col 10: [ 1]  4e
col 11: [ 1]  4e
col 12: [ 1]  4e
col 13: [ 2]  c1 02
tab 0, row 28, @0x13b6


[ 本帖最后由 sundog315 于 2010-6-25 13:43 编辑 ]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/19423/viewspace-666262/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/19423/viewspace-666262/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值