Welcome 微信登录

首页 / 数据库 / MySQL / Oracle datafile block 格式说明

一. DUMP DatafileBlock 示例

       Oracle的一个数据块里的SCN有三种,分别是块头的SCN, CSC (cleanout SCN)和ITL中记录的commit SCN。 如果我们想查看某个或者某些block 里的内容,可以把这些block dump出来查看。关于这个dump 方法,在之前的文章里有说明:       Oracle rdba和 dba 说明 http://www.linuxidc.com/Linux/2011-07/37999.htm        Orace ITL(Interested Transaction List) 说明 http://www.linuxidc.com/Linux/2011-08/40284.htm根据Rowid 查询对应的block number 和datafile number:SQL> SELECT2dbms_rowid.rowid_relative_fno(rowid) REL_FNO,3dbms_rowid.rowid_block_number(rowid) BLOCKNO,4dbms_rowid.rowid_row_number(rowid) ROWNO,5 empno, ename6 FROM emp WHERE empno = 7369;REL_FNO BLOCKNO ROWNO EMPNOENAME---------- -------------------- ---------- ----------4 20 0 7369 SMITH 然后根据block id执行dump 命令:       SQL> alter system dump datafile 4 block 20; 如果要dump 多个block,命令如下:       SQL>ALTER SYSTEM dump datafile <file_id> block min<block_id> block max <block_id+blocks-1>; SYS@anqing2(rac2)> oradebug setmypidStatement processed.SYS@anqing2(rac2)> alter system dump datafile 1 block 292689;System altered.SYS@anqing2(rac2)> oradebug tracefile_name/u01/app/oracle/admin/anqing/udump/anqing2_ora_32276.trc [oracle@rac2 ~]$ cat /u01/app/oracle/admin/anqing/udump/anqing2_ora_32276.trc          *** 2011-08-01 17:51:31.366Start dump data blocks tsn: 0file#: 1 minblk 292689 maxblk 292689buffer tsn: 0 rdba: 0x00447751(1/292689)-- buffertsn:  数据文件对应的tablespace 的 number ,这只是dump文件中记录的数据而已,block 中是没有记录tablespace 的 number 的  scn: 0x0000.005bdee1 seq: 0x01flg: 0x06 tail: 0xdee10601frmt: 0x02 chkval: 0xaf6f type:0x06=trans dataHex dump of block: st=0,typ_found=1Dump of memory from 0x0DC34400to 0x0DC36400DC34400 0000A206 00447751005BDEE1 06010000  [....QwD...[.....]......DC363F0 C3040203 04261C0B65766164 DEE10601  [......&.dave....]Block header dump:  0x00447751 Object id on Block? Y seg/obj: 0xd5ec  csc: 0x00.5bcbe0  itc: 3 flg: -  typ: 1 - DATA     fsl: 0 fnx: 0x0 ver: 0x01  Itl         Xid                 Uba         Flag Lck        Scn/Fsc0x01  0x000e.007.00000236 0x00000000.0000.00  C-U-   0  scn 0x0000.005b1f7f0x02  0x000c.005.000003b4 0x01401727.0144.13  C---   0  scn 0x0000.005bbf0b0x03  0x0011.007.00000406 0x0140015b.00c7.57  --U- 483  fsc 0x0000.005bdee1 data_block_dump,data header at0xdc34474-- 其实这个block不是直接从data buffer 中 dump 出来的,这个表示真正dump时 block 的数据区的起始位置,也就是下面这部分开始的位置 ===============tsiz: 0x1f88-- tsiz:    hsiz:  pbl:   bdba: 在数据文件都是没有存储的--Total data area size  --8k的block: 8192-20(blockhead)-24(Transaction Header)-24*3(一个事务条)-4(block tail)=8072(0x1f88)--将十六进制转换为10进制SYS@anqing2(rac2)> selectto_number("1f88","xxxx") from dual;TO_NUMBER("1F88","XXXX")------------------------                    8072 hsiz: 0x3d8--Data headersize   pbl: 0x0dc34474-- Pointer tobuffer holding the blockbdba: 0x00447751     76543210flag=--------ntab=1nrow=483frre=-1fsbo=0x3d8fseo=0x706avsp=0x32etosp=0x32e0xe:pti[0]      nrow=483        offs=00x12:pri[0]     offs=0x1f7b0x14:pri[1]     offs=0x1f6e......0x3d4:pri[481]  offs=0x7130x3d6:pri[482]  offs=0x706 block_row_dump:tab 0, row 0, @0x1f7btl: 13 fb: --H-FL-- lb:0x3  cc: 2col  0: [ 4] c3 0b 1c 26col  1: [ 4] 64 61 76 65tab 0, row 1, @0x1f6etl: 13 fb: --H-FL-- lb:0x3  cc: 2col  0: [ 4] c3 0b 1c 27col  1: [ 4] 64 61 76 65tab 0, row 2, @0x1f61tl: 13 fb: --H-FL-- lb:0x3  cc: 2col  0: [ 4] c3 0b 1c 28col  1: [ 4] 64 61 76 65......tab 0, row 481, @0x713tl: 13 fb: --H-FL-- lb:0x3  cc: 2col  0: [ 4] c3 0b 21 13col  1: [ 4] 64 61 76 65tab 0, row 482, @0x706tl: 13 fb: --H-FL-- lb:0x3  cc: 2col  0: [ 4] c3 0b 21 14col  1: [ 4] 64 61 76 65--这里的row482 之类的都是每一条记录里的具体值。我dump 这个block 保存的记录比较简单,只有2列值。 可以将这个值转换成具体的字符串。 方法如下: SYS@anqing2(rac2)> setserveroutput onSYS@anqing2(rac2)> declare nnumber;  2 begin  3 dbms_stats.convert_raw_value("c30b2114",n);  4 dbms_output.put_line(n);  5  end;  6  /103219PL/SQL procedure successfullycompleted. SYS@anqing2(rac2)> declarestr varchar2(100);  2 begin  3 dbms_stats.convert_raw_value("64617665",str);  4 dbms_output.put_line(str);  5  end;  6  /dave  --这个就是 col  1: [ 4]  64 61 76 65 对应的值PL/SQL procedure successfullycompleted. end_of_block_dumpEnd dump data blocks tsn: 0file#: 1 minblk 292689 maxblk 292689[oracle@rac2 ~]$
  • 1
  • 2
  • 3
  • 4
  • 下一页
Oracle Block scn/commit scn/cleanout scn 说明Oracle ORA_ROWSCN 伪列 说明相关资讯      Oracle教程 
  • Oracle中纯数字的varchar2类型和  (07/29/2015 07:20:43)
  • Oracle教程:Oracle中查看DBLink密  (07/29/2015 07:16:55)
  • [Oracle] SQL*Loader 详细使用教程  (08/11/2013 21:30:36)
  • Oracle教程:Oracle中kill死锁进程  (07/29/2015 07:18:28)
  • Oracle教程:ORA-25153 临时表空间  (07/29/2015 07:13:37)
  • Oracle教程之管理安全和资源  (04/08/2013 11:39:32)
本文评论 查看全部评论 (0)
表情: 姓名: 字数