Offset | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| ||||||||||||||||
00018000h | 6 | A2 | 0 | 0 | 0c | 0 | 80 | 3 | 8b | 61 | 15 | 0 | 0 | 0 | 3 | 4 |
| type | frmt | spare1/2 | rdba | bas | wrp | seq | flg | ||||||||
The Cache Header The Cache Header :
注:@符号后数字表示块内偏移字节数 Struct kcbh 20 bytes @0 :此结构体共20字节,块内偏移为0字节,即块首。 ub1 type_kcbh @0 :1=undo segment header block; 2=undo data block; 5= data segment header block; 6=data block ub1 frmt_kcbh @1 :应该是用来区分版本。Oracle 8之前值为1,之后为2,我的10g为A2 ub1 spare1_kcbh @2 :未被使用 ub1 spare2_kcbh @3 :未被使用 ub4 rdba_kcbh @4 :0x0380000c 转换成2进制后它的前10 bit 表示file id(算法不确定);后22 bit 表示的block id ub4 bas_kcbh @8 :低位字节(SCN base)ub2 wrp_kcbh @12 :高位字节(SCN wrap) ub1 seq_kcbh @14 :参照http://www.itpub.net/thread-100750-4-1.html ub1 flg_kcbh @15 ub2 chkval_kcbh @16 :跟db_block_checksum 参数有关系。 ub2 spare3_kcbh @18
| ||||||||||||||||
00018010h | 9d | af | 0 | 0 | 1 | 0 | 0 | 0 | 4 | D0 | 0 | 0 | 6a | 51 | 15 | 0 |
| chkval | Spare3 | typ | ? | sid | csc | ||||||||||
The Transaction Header :
Struct ktbbh 72 bytes @20 :共72 bytes,块内偏移量20 bytes ub1 ktbbhtyp @20 :1byte。1=data; 2=index。后面3字节空置 union ktbbhsid @24 :指在OBJ$中记录的segment的object number struct ktbbhcsc @28 : 前6字节为SCN at last block cleanout,后2字节用途不清 b2 ktbbhict @36 : ITL 的slot数量 ub1 ktbbhflg @38 ub1 ktbbhfsl @39 ub4 ktbbhfnx @40 :自由列表中下一块的地址 struct ktbbhitl[2] @44 : 2个ITL 共48字节,块内偏移44字
| ||||||||||||||||
00018020h | 0 | 0 | 0 | 0 | 2 | 0 | 32 | 0 | 9 | 0 | 80 | 3 | 3 | 0 | 5 | 0 |
| csc | ktbbhict | flg | fsl | fnx | xid | ||||||||||
第1个ITL xid : 8bytes。Transaction ID (UndoSeg.Slot.Wrap)(select XIDUSN, XIDSLOT,XIDSQN from v$transaction;) uba : 8bytes。Undo address (UndoDBA.SeqNo.RecordNo) Lck Flag : 2bytes。 Scn/Fsc : 6bytes。Commit SCN或者快速提交(Fast Commit Fsc)的SCN
| ||||||||||||||||
00018030h | 74 | 2 | 0 | 0 | 43 | 3 | 80 | 0 | A2 | 1 | 29 | 0 | 0 | 80 | 0 | 0 |
| xid | uba | Lck Flag | Scn/Fsc | ||||||||||||
00018040h | AE | 10 | 15 | 0 | 2 | 0 | 0C | 0 | 51 | 2 | 0 | 0 | 48 | 0A | 80 | 0 |
| Scn/Fsc | 第2个ITL | ||||||||||||||
00018050h | D7 | 1 | 9 | 0 | 0 | 80 | 0 | 0 | 3D | 14 | 15 | 0 | 0 | 0 | 0 | 0 |
| 第2个ITL | 空闲8个bytes | ||||||||||||||
空闲字节: 8bytes。若用ASSM则需要在此+8字节,否则不需要(未验证)
| ||||||||||||||||
00018060h | 0 | 0 | 0 | 0 | 0 | 1 | 3 | 0 | FF | FF | 18 | 0 | 0E | 8 | F6 | 7 |
| 空闲 | flag | ntab | nrow | frre | fsbo | fseo | avsp | ||||||||
struct kdbh 14 bytes @100 :此结构共14字节,块内偏移量100字节 ub1 kdbhflag @100 :N=pctfree hit(clusters); F=do not put on freelist; K=flushable cluster keys b1 kdbhntab @101 :Number of tables (>1 in clusters) b2 kdbhnrow @102 :block 有多少条数据 sb2 kdbhfrre @104 :First free row entry index; -1 = you have to add one sb2 kdbhfsbo @106 :空闲空间的开始 sb2 kdbhfseo @108 :空闲空间的结尾 b2 kdbhavsp @110 :块中可用空闲空间,单位是bytes b2 kdbhtosp @112 :块中总可用空间
| ||||||||||||||||
00018070h | F6 | 7 | 0 | 0 | 3 | 0 | BF | 17 | 0E | 8 | E7 | 0F | 3D | 5A | 7 | 52 |
| kdbhtosp | kdbtoffs | kdbtnrow | rowoffs1 | Rowoffs2 | Rowoffs3 | freespace | |||||||||
Table Directory Entry Structure :
struct kdbt[1], 4 bytes @114 b2 kdbtoffs @114 b2 kdbtnrow @116
Row Directory :
sb2 kdbr[3] @118 : --共3(记录条数为变量)条记录,每个记录长2 bytes ,块内偏移量118 bytes 。 row offs1 row offs2 row offs3
| ||||||||||||||||
……. | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| freespace | |||||||||||||||
ub1 freespace[2038] @124 --共2038 bytes,块内偏移量124 bytes --[2038] = kdbh.kdbhavsp(十进制) --@124 = kdbh.fsbo(十进制)+ ( 20 + 24 + 24*ITLS + 8 )
| ||||||||||||||||
00018870h | 0 | 0 | 2C | 0 | 2 | 2 | C1 | 4 | FE | D0 | 7 | 61 | 20 | 20 | 20 | 20 |
| freespace | flag | lock | ccnt | lgth | date |
| lgth | date | |||||||
ub1 rowdata[6026] @2162 --共6026 bytes,块内偏移量2162 bytes --@2162 = ( 20 + 24 + 24*ITLS + 8 ) + kdbh.fsbo(十进制) + freespace[2038] --注:本数据块的起始位置 18000h( 十六进制文件的offset ),块内偏移量2162,故rowdata在本块的最后一条(数据块中的数据是从底 向上增长的)数据位置为:00018872h 。实际上:此条数据已被删除,select是查不到的,oracle并未从块中立即清楚delete的数据。从dump文件中计算最后一行数据( 未被删除的 )位置:0001904b h
| ||||||||||||||||
00019040h | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 2c | 0 | 2 | 1 | 80 |
00019050h | fe | D0 | 7 | 61 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 |
行记录结构: flag: 1byte。行状态标志 lock: 1byte。同ITL 的lck相对应 表示这行是否被 lock 了 ccnt: 1byte。该行数据几列 以上三个字节对应kdrh结构中的(ub1 kdrhflag,ub1 kdrhlock,ubl kdrhccnt) Lgth: 列的数据的长度是多少。 1. 0xfa ( 250 bytes ) 其实0xfb,0xfc,0xfd 也同样是250bytes 2. 0xfe fb 00 ( 0xfb 00 表示的251 bytes 0xfe表示row的长度超过了250 bytes) 3. 0xff 表示number 的 null 这也是oracle中null的表现形式排序的时候null最大了 字段的数据超过250字节是就用3bytes来表示字段的长度。因为如果是long类型,它的字段再长 它在这个block中的数据的长度不会超过64K 。所以最长用3bytes来表示行的长度已经够了.再长就链接行了 Data: 实际字段值
| ||||||||||||||||
……. | 0 | 2c | 0 | 2 | 2 | C1 | 4 | fe | D0 | 7 | 61 | 20 | 20 | 20 | 20 | 20 |
| date | |||||||||||||||
00019ff0h | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 20 | 3 | 6 | 8b | 61 |
|
| block tail | ||||||||||||||
ub4 tailchk @8188 --块尾部的4 bytes 第1 byte : 对应开始的 seq 第2 byte : 对应开始的 type 第3,4 byte : 对应开始的SCN的末2位
| ||||||||||||||||
下面结合dump文件对数据块进行分析: The Cache Header : ....... Start dump data blocks tsn: 14 file#: 14 minblk 12 maxblk 12 buffer tsn: 14 rdba: 0x0380000c (14/12) scn: 0x0000.0015618b seq: 0x03 flg: 0x04 tail: 0x618b0603 frmt: 0x02 chkval: 0xaf9d type: 0x06=trans data Hex dump of block: st=0, typ_found=1 注:buffer tsn :14 这个记录只是在dump文件中有记录,在实际的block 中是没有记录的。
The Transaction Header :
Block header dump: 0x0380000c Object id on Block? Y seg/obj: 0xd004 csc: 0x00.15516a itc: 2 flg: E typ: 1 - DATA brn: 0 bdba: 0x3800009 ver: 0x01 opc: 0 inc: 0 exflg: 0 注:brn,ver,inc,exflg 等字段在数据块中未找到相应字节
Itl Xid Uba Flag Lck Scn/Fsc 0x01 0x0003.005.00000274 0x00800343.01a2.29 C--- 0 scn 0x0000.001510ae 0x02 0x0002.00c.00000251 0x00800a48.01d7.09 C--- 0 scn 0x0000.0015143d
data_block_dump,data header at 0xc555a64 =============== tsiz: 0x1f98 --8k block: 8192-20(block head)-24(Transaction Header)-24*2(ITL)-8(空闲块)-4(block tail)=8088(0x1f98) hsiz: 0x18 -- Data header size 数据块头20个字节+数据块尾4个字节=24字节(0x14) pbl: 0x0c555a64 --Pointer to buffer holding the block
注:tsiz,hsiz,pbl并未存储在数据块中
bdba: 0x0380000c 76543210 flag=-------- ntab=1 nrow=3 frre=-1 fsbo=0x18 --空闲空间起始位置距离本块头的距离: 0x18 + ( 20 + 24 + ITL*2 + 8 ) fseo=0x80e --空闲空间结尾位置距离本块头的距离: 0x80e + ( 20 + 24 + ITL*2 + 8 ) avsp=0x7f6 --块中可用空闲空间 avsp = fseo - fsbo tosp=0x7f6 --块中总可用空间 0xe:pti[0] nrow=3 offs=0 0x12:pri[0] offs=0x17bf --第1行行头块内偏移字节:0x17bf + ( 20 + 24 + ITL*2 + 8 ) 0x14:pri[1] offs=0x80e 0x16:pri[2] offs=0xfe7 --最后一条记录块内偏移字节:0xfe7+( 20 + 24 + ITL*2 + 8 ) (表格中说明:0001904b h) block_row_dump: tab 0, row 0, @0x17bf tl: 2009 fb: --H-FL-- lb: 0x0 cc: 2 col 0: [ 2] c1 04 col 1: [2000] 61 20 20…… tab 0, row 1, @0x80e tl: 2009 fb: --H-FL-- lb: 0x0 cc: 2 col 0: [ 2] c1 04 col 1: [2000] 61 20 20…… tab 0, row 2, @0xfe7 tl: 2008 fb: --H-FL-- lb: 0x0 cc: 2 col 0: [ 1] 80 col 1: [2000] 61 20 20……
|
Oracle 摘去数据块的面纱
最新推荐文章于 2021-04-03 04:50:26 发布