SQL> connect test/test@test 已连接 SQL> create table test (a number); 表已创建 SQL> insert into test values(); 已创建 行 SQL> select segment_nameheader_fileheader_block from dba_segments where segmen t_name like TEST; SEGMENT_NAME HEADER_FILE HEADER_BLOCK TEST SQL> alter system dump datafile block ; 系统已更改 DUMP出数据头文件查看itl(interested transaction list) *** :: Start dump data blocks tsn: file#: minblk maxblk buffer tsn: rdba: xac (/) scn: xcd seq: x flg: x tail: xcd frmt: x chkval: x type: x=trans data Block header dump:xac Object id on Block? Y seg/obj: xcsc: xcditc: flg: Otyp: DATA fsl: fnx: x ver: x ItlXidUbaFlagLck Scn/Fsc x xid:x uba: xdc fsc xc /*这里可以看到xid= x(事务id) uba= xdc(undo block address) lck=(受影响的行数) 根据Xid的结构得到 x x – Undo Segment Number – Transaction Table Slot Number – Wrap 根据uba的结构得到 xdc xdc– Address of the last undo block used – Sequence – Last Entry in UNDO record map */ data_block_dump =============== 以下省略 根据 x – Undo Segment Number SQL>select asegment_nameaheader_fileaheader_block from dba_segments adba _rollback_segs b where asegment_name=bsegment_name and bsegment_id=; SEGMENT_NAME HEADER_FILE HEADER_BLOCK RBS 然后dump rbs头查看trans table Start dump data blocks tsn: file#: minblk maxblk buffer tsn: rdba: xdc (/) scn: xcd seq: x flg: x tail: xcde frmt: x chkval: x type: xe=KTU UNDO HEADER W/UNLIMITED EXTENTS Extent Control Header
Extent Header:: spare: space: #extents: #blocks: last mapx#maps: offset: Highwater::xdcext#: blk#: ext size: #blocks in seg hdrs freelists: #blocks below: mapblkxoffset: Unlocked Map Header:: nextx#extents: obj#: flag: x Extent Map
xdclength: xdlength: xlength: xlength: xlength: xclength: xlength: xclength: TRN CTL:: seq: x chd: x ctl: x inc: x nfb: x mgc: x xts: x flg: x opt: (xffffffe) uba: xdc scn: x Version: x FREE BLOCK POOL:: uba: x ext: xspc: x uba: x ext: xspc: x uba: x ext: xspc: x uba: x ext: xspc: x uba: x ext: xspc: x TRN TBL:: indexstate cflagswrap#uel scndba parentxidnub
x xxxxcdxdcxx xxxxxxxx 以下省略 根据从xid中得到的 – Transaction Table Slot Number 去找到事务表中记载的undo块的地址dba=xdc(也可从uba中直接得到) 接下来我们来看一下undo头的地址rdba: xdc (/) 所以我们去dump 即undo头+ *** :: Start dump data blocks tsn: file#: minblk maxblk buffer tsn: rdba: xdc (/) scn: xcd seq: x flg: x tail: xcd frmt: x chkval: x type: x=KTU UNDO BLOCK ******************************************************************************** UNDO BLK: xid: xseq: x cnt: x irb: x icl: x flg: x Rec OffsetRec OffsetRec OffsetRec OffsetRec Offset
x xf x xf x xeb x xe x xde * * Rec #xslt: xobjn: (x)objd: tblspc: (x) * Layer: (Row) opc: rci x Undo type:Regular undoBegin transLast buffer split:No Temp Object:No Tablespace Undo:No rdba: x * uba: x ctl max scn: x prv tx scn: x KDO undo record: KTB Redo op: xver: x op: Litl: scn:xd uba: xfa flg: CUlkc: scn: xccf KDO Op code: DRPxtype: XAbdba: xachdba: xab itli: ispac: maxfr: tabn: slot: (x) 根据KDO Op code: DRP表明反操作是delete所以我们可以知道这就是刚才insert后在undo segment里记载的信息 我们知道当发生insert的时候undo segment里仅记载了记录的rowid下面我们把它找出来 SQL> select rowid from test; ROWID
AAAGSHAABAAAIoAAC Translate the value: AAAGSHAABAAAIoAAC Data Object number = AAAGSH File = AAB Block = AAAIo ROW = AAC 然后根据公式转换 得到data object number= file= block= row= |