BBED> set dba 1,58914 DBA 0x0040e622 (4253218 1,58914) BBED> map File: /u01/app/oracle/oradata/qxptfh01/system01.dbf (1) Block: 58914 Dba:0x0040e622 ------------------------------------------------------------ KTB Data Block (Table/Cluster) struct kcbh, 20 bytes @0 -- - Cache Layer - struct ktbbh, 72 bytes @20 --- Transaction Layer - struct kdbh, 14 bytes @92 -- Data Header - struct kdbt[1], 4 bytes @106 -- Table Directory - sb2 kdbr[3] @110 - Row Directory - ub1 freespace[8041] @116 - Free Space - ub1 rowdata[31] @8157 - Row Data - ub4 tailchk @8188 -- Tailchk -
從Data header到Row Data部分合稱Data Layer。
Cache Layer:Block的第一部分,長度爲20字節,內部數據結構名爲kcbh,包括
下列幾部分
BBED> p kcbh struct kcbh, 20 bytes @0 ub1 type_kcbh @0 0x06 --塊類型(table/index,rollback segment,temporary segment等) ub1 frmt_kcbh @1 0xa2 --塊格式(v6,v7,v8) ub1 spare1_kcbh @2 0x00 --保留 ub1 spare2_kcbh @3 0x00 --保留 ub4 rdba_kcbh @4 0x0040e622 --塊地址DBA ub4 bas_kcbh @8 0x01a9b470 --scn base ub2 wrp_kcbh @12 0x0000 --scn wrap ub1 seq_kcbh @14 0x07 --塊的序列號,設置爲0xff,則認爲是壞塊。 ub1 flg_kcbh @15 0x06 (KCBHFDLC, KCBHFCKV) --塊的標誌,即塊的屬性。 ub2 chkval_kcbh @16 0x153c --校驗值,db_block_checksum=true,纔有值。 ub2 spare3_kcbh @18 0x0000 --保留
flg_kcbh:
define KCBHFNEW 0×01 /* new block - zeroed data area */
#define KCBHFDLC 0×02 /* Delayed Logging Change advance SCN/seq */
#define KCBHFCKV 0×04 /* ChecK Value saved-block xor’s to zero */
#define KCBHFTMP 0×08 /* Temporary block */
這是一個可以組合的值 也就是說有爲 6 的時候是 2,4 兩種情況的組合
type_kcbh:
Transaction Layer:內部結構名kcbbh。分成兩部分:
第一部分爲固定長度,長度爲24字節,包含事務相關的一些基本信息。
第二部分爲可變長度,包含itl,長度根據itl條目的個數變化,每個itl長度爲24字節,內部結構名ktbbhitl。
BBED> p ktbbh struct ktbbh, 72 bytes @20 ub1 ktbbhtyp @20 0x01 (KDDBTDATA) --塊類型。1爲表,2爲索引 union ktbbhsid, 4 bytes @24 --段或者對象的ID,也就是下邊的0x00016f66轉換爲10進制就是 ub4 ktbbhsg1 @24 0x00016f66 --段號 ub4 ktbbhod1 @24 0x00016f66 --對象號 struct ktbbhcsc, 8 bytes @28 --最後一次塊清除的SCNub4 kscnbas @28 0x01a9b461 --scn base ub2 kscnwrp @32 0x0000 --scn wrap b2 ktbbhict @36 2 --事務槽個數(ITL NUMBER) ub1 ktbbhflg @38 0x03 (KTBFONFL) --0 = ON THE FREELIST ub1 ktbbhfsl @39 0x00 --ITL TX FREELIST SLOT ub4 ktbbhfnx @40 0x00000000 --下一個空閒塊的地址 dba struct ktbbhitl[0], 24 bytes @44 --事務槽1 struct ktbitxid, 8 bytes @44 --xid ub2 kxidusn @44 0x0007 --usn ub2 kxidslt @46 0x002d --slot ub4 kxidsqn @48 0x0000150a --seq struct ktbituba, 8 bytes @52 --uba ub4 kubadba @52 0x008008b0 --dba ub2 kubaseq @56 0x145d --seq ub1 kubarec @58 0x36 --ubarec ub2 ktbitflg @60 0x2003 (KTBFUPB) union _ktbitun, 2 bytes @62 b2 _ktbitfsc @62 0 ub2 _ktbitwrp @62 0x0000 ub4 ktbitbas @64 0x01a9b470 struct ktbbhitl[1], 24 bytes @68 --事務槽2 struct ktbitxid, 8 bytes @68 ub2 kxidusn @68 0x0000 ub2 kxidslt @70 0x0000 ub4 kxidsqn @72 0x00000000 struct ktbituba, 8 bytes @76 ub4 kubadba @76 0x00000000 ub2 kubaseq @80 0x0000 ub1 kubarec @82 0x00 ub2 ktbitflg @84 0x0000 (NONE) union _ktbitun, 2 bytes @86 b2 _ktbitfsc @86 0 ub2 _ktbitwrp @86 0x0000 ub4 ktbitbas @88 0x00000000
下面通過ub4 ktbbhod1 @24 0x00016f66 查詢對應的是哪個對象:
SQL> select to_number('00016f66','xxxxxxxx') from dual; TO_NUMBER('00016F66','XXXXXXXX') -------------------------------- 94054 SQL> col OBJECT_NAME FORMAT A15; SQL> COL OBJECT_TYPE FORMAT A15 SQL> select object_name,object_type from dba_objects where object_id='94054'; OBJECT_NAME OBJECT_TYPE --------------- --------------- T1 TABLE
Data Layer:包括Data Header,Table Directory,Row Directory,Free Space和Row Data。其中
Data Header:長度14字節,內部數據結構名kdbh
BBED> p kdbh struct kdbh, 14 bytes @92 ub1 kdbhflag @92 0x00 (NONE) --標誌位 (N:pctfree hit. F:do not put on freelist. K:flushable cluster keys) b1 kdbhntab @93 1 --表的個數 b2 kdbhnrow @94 3 --這個塊的行數 sb2 kdbhfrre @96 -1 --是否在空閒列表。-1:不在空閒列表 sb2 kdbhfsbo @98 24 --空閒空間的開始offset sb2 kdbhfseo @100 8065 --空閒空間的結束offset b2 kdbhavsp @102 8041 --塊的平均空間 b2 kdbhtosp @104 8041 --總共可以用的空間
Table Directory: 一般table只有一個條目,cluster則有一個或多個條目。每個條目長4字節,內部數據結構名kdbt。
BBED> p kdbt struct kdbt[0], 4 bytes @106 b2 kdbtoffs @106 0 b2 kdbtnrow @108 3
Row Directory:數目由塊中數據的行數決定,每個條目長2字節,內部數據結構名kdbr
BBED> p kdbr sb2 kdbr[0] @110 8085 sb2 kdbr[1] @112 8075 sb2 kdbr[2] @114 8065
Free Space:表示數據塊中可用空間,內部數據結構名freespace
Row Data:表示實際的數據,內部數據結構名rowdata
BBED> p freespace ub1 freespace[0] @116 0x00 ub1 freespace[1] @117 0x00 ub1 freespace[2] @118 0x00 ub1 freespace[3] @119 0x00 .........................................................
BBED> p rowdata ub1 rowdata[0] @8157 0x2c ub1 rowdata[1] @8158 0x01 ub1 rowdata[2] @8159 0x02 ub1 rowdata[3] @8160 0x02 ub1 rowdata[4] @8161 0xc1 ub1 rowdata[5] @8162 0x04 ub1 rowdata[6] @8163 0x03 ub1 rowdata[7] @8164 0x78 ub1 rowdata[8] @8165 0x6e...........................................................................................
Tailchk:保存在塊結尾用於校驗的數據,長度4個字節,內部結構名tailchk。
tailchk=bas_kcbh最後兩2字節(b470)+type_kcbh(06)+seq_kcbh(07).
BBED> p tailchk ub4 tailchk @8188 0xb4700607 --尾部校驗碼。
下面是文件頭塊信息:
BBED> set dba 1,1 DBA 0x00400001 (4194305 1,1) BBED> map File: /u01/app/oracle/oradata/qxptfh01/system01.dbf (1) Block: 1 Dba:0x00400001 ------------------------------------------------------------ Data File Header struct kcvfh, 676 bytes @0 ub4 tailchk @8188 BBED> p kcvfh struct kcvfh, 676 bytes @0 struct kcvfhbfh, 20 bytes @0 ub1 type_kcbh @0 0x0b -----數據的塊類型 11可以看出是否是數據文件頭 ub1 frmt_kcbh @1 0xa2 -----數據塊的格式。1=oracle7 ,2=oracle8+ ub1 spare1_kcbh @2 0x00 ub1 spare2_kcbh @3 0x00 ub4 rdba_kcbh @4 0x00400001 ub4 bas_kcbh @8 0x00000000 ---SCN BASE ub2 wrp_kcbh @12 0x0000 ---SCN WRAP ub1 seq_kcbh @14 0x01 ---SCN序列號 ub1 flg_kcbh @15 0x04 (KCBHFCKV) ----塊屬性 ub2 chkval_kcbh @16 0x5064 ---檢驗值 ub2 spare3_kcbh @18 0x0000 struct kcvfhhdr, 76 bytes @20 ---此結構存儲這個數據文件的屬性 ub4 kccfhswv @20 0x00000000 ub4 kccfhcvn @24 0x0a200500 ---文件創建的版本號 ub4 kccfhdbi @28 0x783cfa8c ---數據庫的DBID text kccfhdbn[0] @32 Q ---所屬實例的名字 text kccfhdbn[1] @33 X text kccfhdbn[2] @34 P text kccfhdbn[3] @35 T text kccfhdbn[4] @36 F text kccfhdbn[5] @37 H text kccfhdbn[6] @38 0 text kccfhdbn[7] @39 1 ub4 kccfhcsq @40 0x00003db5 ---控制序列,控制文件事務會增加此值 ub4 kccfhfsz @44 0x0000f000 ---文件當前所包含數據塊的個數 s_blkz kccfhbsz @48 0x00 ---文件存放的塊大小,關閉數據庫有值 ub2 kccfhfno @52 0x0001 ---文件號 ub2 kccfhtyp @54 0x0003 ---文件類型,03代表數據文件,06表示undo文件 ub4 kccfhacid @56 0x00000000 ---活動ID ub4 kccfhcks @60 0x00000000 ---創建檢查點的SCN text kccfhtag[0] @64 text kccfhtag[1] @65 text kccfhtag[2] @66 text kccfhtag[3] @67 text kccfhtag[4] @68 text kccfhtag[5] @69 text kccfhtag[6] @70 text kccfhtag[7] @71 text kccfhtag[8] @72 text kccfhtag[9] @73 text kccfhtag[10] @74 text kccfhtag[11] @75 text kccfhtag[12] @76 text kccfhtag[13] @77 text kccfhtag[14] @78 text kccfhtag[15] @79 text kccfhtag[16] @80 text kccfhtag[17] @81 text kccfhtag[18] @82 text kccfhtag[19] @83 text kccfhtag[20] @84 text kccfhtag[21] @85 text kccfhtag[22] @86 text kccfhtag[23] @87 text kccfhtag[24] @88 text kccfhtag[25] @89 text kccfhtag[26] @90 text kccfhtag[27] @91 text kccfhtag[28] @92 text kccfhtag[29] @93 text kccfhtag[30] @94 text kccfhtag[31] @95 ub4 kcvfhrdb @96 0x00400179 ---ROOT DBA struct kcvfhcrs, 8 bytes @100 ---文件創建的SCN ub4 kscnbas @100 0x00000007 ---SCN BASE ub2 kscnwrp @104 0x0000 ---SCN WRAP ub4 kcvfhcrt @108 0x2ab9923a ---文件創建的時間戳 ub4 kcvfhrlc @112 0x30f3d1cf ---resetlogs的次數 struct kcvfhrls, 8 bytes @116 ---resetlogs的SCN ub4 kscnbas @116 0x0005eca9 ---SCN BASE ub2 kscnwrp @120 0x0000 ---SCN WRAP ub4 kcvfhbti @124 0x00000000 struct kcvfhbsc, 8 bytes @128 ---備份的SCN ub4 kscnbas @128 0x00000000 ---SCN BASE ub2 kscnwrp @132 0x0000 ---SCN WRAP ub2 kcvfhbth @136 0x0000 ub2 kcvfhsta @138 0x2004 (KCVFHOFZ) ---數據文件狀態:04爲正常,00爲關閉,01爲begin backup struct kcvfhckp, 36 bytes @484 ---檢查點checkpoint struct kcvcpscn, 8 bytes @484 ---數據文件改變的檢查點SCN ub4 kscnbas @484 0x01a947ff --SCN BASE ub2 kscnwrp @488 0x0000 --SCN WRAP ub4 kcvcptim @492 0x338a07e7 --最後改變的時間 ub2 kcvcpthr @496 0x0001 --resetlogs的線程號 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x000005a0 --序列號 ub4 kcrbabno @504 0x00000002 --塊號 ub2 kcrbabof @508 0x0010 --偏移量offset ub1 kcvcpetb[0] @512 0x02 --最大線程數 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00 ub4 kcvfhcpc @140 0x00000619 --數據文件發生checkpoint的次數 ub4 kcvfhrts @144 0x3348a98a --resetlogs的次數 ub4 kcvfhccc @148 0x00000618 --控制文件記錄的檢查點次數 struct kcvfhbcp, 36 bytes @152 struct kcvcpscn, 8 bytes @152 ub4 kscnbas @152 0x00000000 ub2 kscnwrp @156 0x0000 ub4 kcvcptim @160 0x00000000 ub2 kcvcpthr @164 0x0000 union u, 12 bytes @168 struct kcvcprba, 12 bytes @168 ub4 kcrbaseq @168 0x00000000 ub4 kcrbabno @172 0x00000000 ub2 kcrbabof @176 0x0000 ub1 kcvcpetb[0] @180 0x00 ub1 kcvcpetb[1] @181 0x00 ub1 kcvcpetb[2] @182 0x00 ub1 kcvcpetb[3] @183 0x00 ub1 kcvcpetb[4] @184 0x00 ub1 kcvcpetb[5] @185 0x00 ub1 kcvcpetb[6] @186 0x00 ub1 kcvcpetb[7] @187 0x00 ub4 kcvfhbhz @312 0x00000000 struct kcvfhxcd, 16 bytes @316 ub4 space_kcvmxcd[0] @316 0x00000000 ub4 space_kcvmxcd[1] @320 0x00000000 ub4 space_kcvmxcd[2] @324 0x00000000 ub4 space_kcvmxcd[3] @328 0x00000000 word kcvfhtsn @332 0 --表空間號 ub2 kcvfhtln @336 0x0006 text kcvfhtnm[0] @338 S --表空間的名字,最長爲30字符 text kcvfhtnm[1] @339 Y text kcvfhtnm[2] @340 S text kcvfhtnm[3] @341 T text kcvfhtnm[4] @342 E text kcvfhtnm[5] @343 M text kcvfhtnm[6] @344 text kcvfhtnm[7] @345 text kcvfhtnm[8] @346 text kcvfhtnm[9] @347 text kcvfhtnm[10] @348 text kcvfhtnm[11] @349 text kcvfhtnm[12] @350 text kcvfhtnm[13] @351 text kcvfhtnm[14] @352 text kcvfhtnm[15] @353 text kcvfhtnm[16] @354 text kcvfhtnm[17] @355 text kcvfhtnm[18] @356 text kcvfhtnm[19] @357 text kcvfhtnm[20] @358 text kcvfhtnm[21] @359 text kcvfhtnm[22] @360 text kcvfhtnm[23] @361 text kcvfhtnm[24] @362 text kcvfhtnm[25] @363 text kcvfhtnm[26] @364 text kcvfhtnm[27] @365 text kcvfhtnm[28] @366 text kcvfhtnm[29] @367 ub4 kcvfhrfn @368 0x00000001 --相對文件號 struct kcvfhrfs, 8 bytes @372 --文件SCN ub4 kscnbas @372 0x00000000 --SCN BASE ub2 kscnwrp @376 0x0000 --SCN WRAP ub4 kcvfhrft @380 0x00000000 struct kcvfhafs, 8 bytes @384 --絕對文件號 ub4 kscnbas @384 0x00000000 --SCN BASE ub2 kscnwrp @388 0x0000 --SCN WRAP ub4 kcvfhbbc @392 0x00000000 ub4 kcvfhncb @396 0x00000000 ub4 kcvfhmcb @400 0x00000000 ub4 kcvfhlcb @404 0x00000000 ub4 kcvfhbcs @408 0x00000000 ub2 kcvfhofb @412 0x000a ub2 kcvfhnfb @414 0x000a ub4 kcvfhprc @416 0x2ab99238 --上個resetlogs的次數 struct kcvfhprs, 8 bytes @420 --上個resetlogs的SCN ub4 kscnbas @420 0x00000001 ub2 kscnwrp @424 0x0000 struct kcvfhprfs, 8 bytes @428 ub4 kscnbas @428 0x00000000 ub2 kscnwrp @432 0x0000 ub4 kcvfhtrt @444 0x00000000 BBED>
type_kcbh:數據的塊類型