How to Interpret ROWID

本文详细解析了 Oracle 数据库中 ROWID 的内部存储结构及转换原理。ROWID 由 data_object_id、rdba 和 nrow 组成,通过具体实例展示了如何从 VARCHAR2 格式的 ROWID 中获取数据对象 ID、相对文件号及块 ID 等信息。
Oracle ROWID's internal storage is total 10 byte(data_object_id.rdba.nrow), where data_object_id is 4bytes, rdba is 4 bytes and nrow is 2 bytes,and rdba include rfn and blockid,when you use "select rowid from tname" to display the rowid in varchar2 format, oracle do the following convert:[@more@]

SQL> SELECT ROWID FROM TEST.TEST4;

ROWID
------------------
AAABCmAAEAAACxqAAA
AAABCmAAEAAACxqAAB
AAABCmAAEAAACxqAAC
AAABCmAAEAAACxqAAD
AAABCmAAEAAACxqAAE
AAABCmAAEAAACxqAAF
AAABCmAAEAAACxqAAG
AAABCmAAEAAACxqAAH
AAABCmAAEAAACxrAAA

9 rows selected.

SQL> SELECT DATA_OBJECT_ID FROM ALL_OBJECTS WHERE OBJECT_NAME='TEST4';

DATA_OBJECT_ID
--------------
4262

Where each character displayed above is an oracle 64 bit expression as following:

0

1

2

3

4

5

6

7

8

9

0-

A

B

C

D

E

F

G

H

I

J

1-

K

L

M

N

O

P

Q

R

S

T

2-

U

V

W

X

Y

Z

a

b

c

d

3-

e

f

g

h

i

j

k

l

m

n

4-

o

p

q

r

s

t

u

v

w

x

5-

y

z

0

1

2

3

4

5

6

7

6-

8

9

+

/

Then AAABCmAAEAAACxqAAA is splitted as AAABCm.AAE.AAACxq.AAA,

AAABCm = 0,0,0,1,2,38 = 12+2*64+1*64*64=38+128+4096=4262 (data object id)
AAE=0,0,4=4 (relative file number)
AAACxq=0,0,0,2,49,42=2*64*64+49*64+42=8192+3136+42=11370 (block id)
AAA=0,0,0=0 (row index in block)

Accoding to the result calculated above, compare the dump result:

DUL> oradump file 4 block 11370
RDBA=0x01002c6a(4/11370),type=0x06,fmt=0x02,seq=0x02,flag=0x00
seg/obj=0x000010a6=4262,csc=0x0000.001800ca,itc=1,typ=1 - DATA
Transaction Slot:
id xid-usn.slot.wrap uba-rdba.row.seq flag lock fsc/scn
---- ------------------- ------------------ ---- ---- ---------------
0x01 0x0005.05f.0000004d 0x008000cf.0056.2d C--- 0 0x0000.00137db2
Block Data:
hdsz=68
ntab=1
nrow=8
ffre=65535
fsbo=0x0066=102
fseo=0x01f6=502
avsp=0x019e=414
tosp=0x019e=414
tab#= 0 nrow= 8 offs= 0
row#= 0 offs=0x01b2= 434+ 68=0x01f6= 502 flag=--H-FL--
row#= 1 offs=0x05a3= 1443+ 68=0x05e7= 1511 flag=--H-FL--
row#= 2 offs=0x0994= 2452+ 68=0x09d8= 2520 flag=--H-FL--
row#= 3 offs=0x0d85= 3461+ 68=0x0dc9= 3529 flag=--H-FL--
row#= 4 offs=0x1176= 4470+ 68=0x11ba= 4538 flag=--H-FL--
row#= 5 offs=0x1567= 5479+ 68=0x15ab= 5547 flag=--H-FL--
row#= 6 offs=0x1958= 6488+ 68=0x199c= 6556 flag=--H-FL--
row#= 7 offs=0x1d49= 7497+ 68=0x1d8d= 7565 flag=--H-FL--

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

转载于:http://blog.itpub.net/814/viewspace-852156/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值