
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 -
成都创新互联专业为企业提供鸡泽网站建设、鸡泽做网站、鸡泽网站设计、鸡泽网站制作等企业网站建设、网页设计与制作、鸡泽企业网站模板建站服务,10余年鸡泽做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
从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:数据的块类型

名称栏目:使用BBED了解数据块结构
文章网址:http://www.scyingshan.cn/article/gciped.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 