| |
很多时候我们在进行进一步研究时需要转储(dump)oracle的数据块,以研究其内容,oracle提供了很好的方式,我们通过以下例子简单说明一下:
[oracle@jumper udump]$ sqlplus "/ as sysdba"
sql*plus: release 9.2.0.3.0 - production on tue aug 31 17:01:27 2004
copyright (c) 1982, 2002, oracle corporation. all rights reserved.
connected to:
oracle9i enterprise edition release 9.2.0.3.0 - production
with the partitioning, olap and oracle data mining options
jserver release 9.2.0.3.0 - production
sql> select rowid,deptno,dname,loc from scott.dept;
rowid deptno dname loc
------------------ ---------- -------------- -------------
aaadz7aabaaagk6aaa 10 accounting new york
aaadz7aabaaagk6aab 20 research dallas
aaadz7aabaaagk6aac 30 sales chicago
aaadz7aabaaagk6aad 40 operations boston
sql> select file_id,block_id,blocks from dba_extents where segment_name='dept';
file_id block_id blocks
---------- ---------- ----------
1 25273 8
sql> alter system dump datafile 1 block min 25273 block max 25274;
system altered.
sql> !
[oracle@jumper udump]$ ls -l
total 4
-rw-r----- 1 oracle dba 3142 aug 31 17:04 hsjf_ora_13674.trc
[oracle@jumper udump]$ more hsjf_ora_13674.trc
/opt/oracle/admin/hsjf/udump/hsjf_ora_13674.trc
oracle9i enterprise edition release 9.2.0.3.0 - production
with the partitioning, olap and oracle data mining options
jserver release 9.2.0.3.0 - production
oracle_home = /opt/oracle/product/9.2.0
system name: linux
node name: jumper.hurray.com.cn
release: 2.4.18-14
version: #1 wed sep 4 13:35:50 edt 2002
machine: i686
instance name: hsjf
redo thread mounted by this instance: 1
oracle process number: 9
unix process pid: 13674, image: oracle@jumper.hurray.com.cn (tns v1-v3)
*** 2004-08-31 17:04:27.820
*** session id:(8.3523) 2004-08-31 17:04:27.819
start dump data blocks tsn: 0 file#: 1 minblk 25273 maxblk 25274
buffer tsn: 0 rdba: 0x004062b9 (1/25273)
scn: 0x0000.0057c70d seq: 0x01 flg: 0x04 tail: 0xc70d1001
frmt: 0x02 chkval: 0x12e3 type: 0x10=data segment header - unlimited
extent control header
-----------------------------------------------------------------
extent header:: spare1: 0 spare2: 0 #extents: 1 #blocks: 7
last map 0x00000000 #maps: 0 offset: 4128
highwater:: 0x004062bb ext#: 0 blk#: 1 ext size: 7
#blocks in seg. hdr's freelists: 1
#blocks below: 1
mapblk 0x00000000 offset: 0
unlocked
map header:: next 0x00000000 #extents: 1 obj#: 13947 flag: 0x40000000
extent map
-----------------------------------------------------------------
0x004062ba length: 7
nfl = 1, nfb = 1 typ = 1 nxf = 0 ccnt = 1
seg lst:: flg: used lhd: 0x004062ba ltl: 0x004062ba
buffer tsn: 0 rdba: 0x004062ba (1/25274)
scn: 0x0000.0131909b seq: 0x07 flg: 0x04 tail: 0x909b0607
frmt: 0x02 chkval: 0xa8e7 type: 0x06=trans data
block header dump: 0x004062ba
object id on block? y
seg/obj: 0x367b csc: 0x00.131909a itc: 2 flg: o typ: 1 - data
fsl: 0 fnx: 0x0 ver: 0x01
itl xid uba flag lck scn/fsc
0x01 0x0001.02a.000003f3 0x0080000b.0188.08 c--- 0 scn 0x0000.0057c70e
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
data_block_dump,data header at 0xadb505c
===============
tsiz: 0x1fa0
hsiz: 0x1a
pbl: 0x0adb505c
bdba: 0x004062ba
76543210
flag=--------
ntab=1
nrow=4
frre=-1
fsbo=0x1a
fseo=0x1f44
avsp=0x1f2a
tosp=0x1f2a
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] offs=0x1f86
0x14:pri[1] offs=0x1f70
0x16:pri[2] offs=0x1f5c
0x18:pri[3] offs=0x1f44
block_row_dump:
tab 0, row 0, @0x1f86
tl: 26 fb: --h-fl-- lb: 0x0 cc: 3
col 0: [ 2] c1 0b
col 1: [10] 41 43 43 4f 55 4e 54 49 4e 47
col 2: [ 8] 4e 45 57 20 59 4f 52 4b
tab 0, row 1, @0x1f70
tl: 22 fb: --h-fl-- lb: 0x0 cc: 3
col 0: [ 2] c1 15
col 1: [ 8] 52 45 53 45 41 52 43 48
col 2: [ 6] 44 41 4c 4c 41 53
tab 0, row 2, @0x1f5c
tl: 20 fb: --h-fl-- lb: 0x0 cc: 3
col 0: [ 2] c1 1f
col 1: [ 5] 53 41 4c 45 53
col 2: [ 7] 43 48 49 43 41 47 4f
tab 0, row 3, @0x1f44
tl: 24 fb: --h-fl-- lb: 0x0 cc: 3
col 0: [ 2] c1 29
col 1: [10] 4f 50 45 52 41 54 49 4f 4e 53
col 2: [ 6] 42 4f 53 54 4f 4e
end_of_block_dump
end dump data blocks tsn: 0 file#: 1 minblk 25273 maxblk 25274
|
很多人经常提出的一个问题是,rdba是如何转换的?
rdba: 0x004062ba (1/25274)
我们通过这个例子介绍一下.
rdba从oracle6->oracle7->oracle8发生了三次改变:
在oracle6中,rdba由6位2进制数表示,也就是说数据块最多只能有2^6=64个数据文件(去掉全0和全1, 实际上最多只能代表62个文件)
在oracle7中,rdba中的文件号增加为10位,为了向后兼容,从block号的高位拿出4位作为文件号的高位.这样从6->7的rowid无需发生变化.
在oracle8中,文件号仍然用10位表示,只是不再需要置换,为了向后兼容,同时引入了相对文件号(rfile#),所以从oracle7到oracle8,rowid仍然无需发生变化.
举例说明如下:
在oracle6中:
比如: file 8, block 56892
26位block号==56892
vv vvvvvvvv vvvvvvvv vvvvvvvv
00100000 00000000 11011110 00111100
^^^^^^
6位文件号==8
在oracle7中:
比如:file 255, block 56892
11111100 11000000 11011110 00111100
f c c 0 d e 3 c
\_____/\___/\_______________________/
| | |
| | block = 0xde3c = 56892
\_____________
| \
v v
0011 111111 = 0xff = 255 --注意这里高位和低位要置换才能得出正确的file#
在oracle8中:
比如:file 255, block 56892
11111100 11000000 11011110 00111100
f c c 0 d e 3 c
\_____/\___/\_______________________/
| | |
| | block = 0xde3c = 56892
\_____________
| \
v v
0011 1111 0011 = 03f3 = 1011 --这就是相对文件号
对于我们测试中的例子:
rdba: 0x004062ba (1/25274)
也就是:0000 0000 0100 0000 0110 0010 1011 1010
前10位为rfile#: 0000 0000 01 = 1
后22位为block#:00 0000 0110 0010 1011 1010 = 25274
|