首页 > 开发 > 综合 > 正文

数据块转储及RDBA的转换

2024-07-21 02:07:35
字体:
来源:转载
供稿:网友

最大的网站源码资源下载站,


数据块转储及rdba的转换

原文链接:

http://www.eygle.com/internal/how_to_dump_datablock.htm

tuesday, 2004-08-31 17:51 eygle

 
很多时候我们在进行进一步研究时需要转储(dump)oracle的数据块,以研究其内容,oracle提供了很好的方式,我们通过以下例子简单说明一下:






[[email protected] udump]$ sqlplus "/ as sysdba"sql*plus: release 9.2.0.3.0 - production on tue aug 31 17:01:27 2004copyright (c) 1982, 2002, oracle corporation. all rights reserved.connected to:oracle9i enterprise edition release 9.2.0.3.0 - productionwith the partitioning, olap and oracle data mining optionsjserver release 9.2.0.3.0 - productionsql> select rowid,deptno,dname,loc from scott.dept;rowid deptno dname loc------------------ ---------- -------------- -------------aaadz7aabaaagk6aaa 10 accounting new yorkaaadz7aabaaagk6aab 20 research dallasaaadz7aabaaagk6aac 30 sales chicagoaaadz7aabaaagk6aad 40 operations bostonsql> select file_id,block_id,blocks from dba_extents where segment_name='dept'; file_id block_id blocks---------- ---------- ---------- 1 25273 8sql> alter system dump datafile 1 block min 25273 block max 25274;system altered.sql> ![[email protected] udump]$ ls -ltotal 4-rw-r----- 1 oracle dba 3142 aug 31 17:04 hsjf_ora_13674.trc[[email protected] udump]$ more hsjf_ora_13674.trc /opt/oracle/admin/hsjf/udump/hsjf_ora_13674.trcoracle9i enterprise edition release 9.2.0.3.0 - productionwith the partitioning, olap and oracle data mining optionsjserver release 9.2.0.3.0 - productionoracle_home = /opt/oracle/product/9.2.0system name: linuxnode name: jumper.hurray.com.cnrelease: 2.4.18-14version: #1 wed sep 4 13:35:50 edt 2002machine: i686instance name: hsjfredo thread mounted by this instance: 1oracle process number: 9unix process pid: 13674, image: [email protected] (tns v1-v3)*** 2004-08-31 17:04:27.820*** session id:(8.3523) 2004-08-31 17:04:27.819start dump data blocks tsn: 0 file#: 1 minblk 25273 maxblk 25274buffer tsn: 0 rdba: 0x004062b9 (1/25273)scn: 0x0000.0057c70d seq: 0x01 flg: 0x04 tail: 0xc70d1001frmt: 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: 0x909b0607frmt: 0x02 chkval: 0xa8e7 type: 0x06=trans datablock 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/fsc0x01 0x0001.02a.000003f3 0x0080000b.0188.08 c--- 0 scn 0x0000.0057c70e0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000 data_block_dump,data header at 0xadb505c===============tsiz: 0x1fa0hsiz: 0x1apbl: 0x0adb505cbdba: 0x004062ba 76543210flag=--------ntab=1nrow=4frre=-1fsbo=0x1afseo=0x1f44avsp=0x1f2atosp=0x1f2a0xe:pti[0] nrow=4 offs=00x12:pri[0] offs=0x1f860x14:pri[1] offs=0x1f700x16:pri[2] offs=0x1f5c0x18:pri[3] offs=0x1f44block_row_dump:tab 0, row 0, @0x1f86tl: 26 fb: --h-fl-- lb: 0x0 cc: 3col 0: [ 2] c1 0bcol 1: [10] 41 43 43 4f 55 4e 54 49 4e 47col 2: [ 8] 4e 45 57 20 59 4f 52 4btab 0, row 1, @0x1f70tl: 22 fb: --h-fl-- lb: 0x0 cc: 3col 0: [ 2] c1 15col 1: [ 8] 52 45 53 45 41 52 43 48col 2: [ 6] 44 41 4c 4c 41 53tab 0, row 2, @0x1f5ctl: 20 fb: --h-fl-- lb: 0x0 cc: 3col 0: [ 2] c1 1fcol 1: [ 5] 53 41 4c 45 53col 2: [ 7] 43 48 49 43 41 47 4ftab 0, row 3, @0x1f44tl: 24 fb: --h-fl-- lb: 0x0 cc: 3col 0: [ 2] c1 29col 1: [10] 4f 50 45 52 41 54 49 4f 4e 53col 2: [ 6] 42 4f 53 54 4f 4eend_of_block_dumpend 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 5689226位block号==56892 vv vvvvvvvv vvvvvvvv vvvvvvvv00100000 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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表