Oracle里段头的类型

| No Comments

首先什么是段头?

The segment header is the header block of the first extent of a segment. In Free List Managed (FLM) segments the header block is always the first block of a segment. In Automatic Segment Space Managed (ASSM) segments, the bitmap blocks always appear before the header block within the first extent of the segment.

The segment header contains information on the extents allocated to the segment and free space within the segment.

 

接着我们来看oracle里段头的具体类型:

0x01  undo segment header

0x0b  data file header

0x0c  data segment header with FLG blocks

0x0e  unlimited undo segment header

0x0f  unlimited save undo segment header

0x10  unlimited data segment header

0x11  unlimited data segment header with FLG blocks

0x12  extent map block

0x17  bitmapped segment header

0x1d  bitmapped file space header

0x20  first level bitmap block

0x21  second level bitmap block

0x22  third level bitmap block

0x23  Pagetable segment header block

0x24  Pagetable extent map block

0x25  System Managed Undo Extent Map Block

 

然后我们来看一个ASSM的实例:

SQL> create tablespace testlmt datafile '/dras20/astca/testlmt01.dbf' size 10M extent management local uniform size 1m segment space management auto;

 

Tablespace created

 

SQL> create table testlmttb tablespace testlmt as select * from dba_objects;

 

Table created

 

SQL> select extent_id,file_id,block_id,bytes from dba_extents where segment_name='TESTLMTTB';

 

 EXTENT_ID    FILE_ID   BLOCK_ID      BYTES

---------- ---------- ---------- ----------

         0        138          9    1048576

         1        138        137    1048576

         2        138        265    1048576

         3        138        393    1048576

 

1datafile header,即段头类型为0x0b

BBED> set file 138

        FILE#           138

 

BBED> set block 1

        BLOCK#          1

 

BBED> dump

 File: /dras20/astca/testlmt01.dbf (138)

 Block: 1                Offsets:    0 to  511           Dba:0x22800001

------------------------------------------------------------------------

 0b020000 22800001 00000000 00000104 4bbb0000 09200000 08000000 df7fd2dd

 41535443 41000000 000102df 00000500 00002000 008a0003 00000000 00000000

 ......省略显示部分内容

 00000000 00000000 00000000 00000059 00075445 53544c4d 54000000 00000000

 

 <32 bytes per line>

 

2bitmapped file space header,即段头类型为0x1d

BBED> set block 2

        BLOCK#          2

 

BBED> dump

 File: /dras20/astca/testlmt01.dbf (138)

 Block: 2                Offsets:    0 to  511           Dba:0x22800002

------------------------------------------------------------------------

 1d020000 22800002 aa35c791 00080204 8a370000 0000008a 00000080 00000500

 00000001 00000000 00000000 00000007 00000488 00000004 00000005 00000000

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

3ASSM里的first level bitmap block,即L1 BMB,段头类型为0x20

BBED> set block 9

        BLOCK#          9

 

BBED> dump

 File: /dras20/astca/testlmt01.dbf (138)

 Block: 9                Offsets:    0 to  511           Dba:0x22800009

------------------------------------------------------------------------

 20020000 22800009 aa35c793 00080304 8ef60000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

这里Block 137138265266393394也是L1 BMB

 

4ASSM里的second level bitmap block,即L2 BMB,段头类型为0x21

BBED> set block 11

        BLOCK#          11

 

BBED> dump

 File: /dras20/astca/testlmt01.dbf (138)

 Block: 11               Offsets:    0 to  511           Dba:0x2280000b

------------------------------------------------------------------------

 21020000 2280000b aa35c793 00080804 a63a0000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

5ASSM里的Pagetable segment header block,即大家从dba_segmentsselect出来的ASSM下的"段头",段头类型为0x23

SQL> select HEADER_FILE,HEADER_BLOCK from dba_segments where segment_name='TESTLMTTB';

 

HEADER_FILE HEADER_BLOCK

----------- ------------

        138           12

 

BBED> set block 12

        BLOCK#          12

 

BBED> dump

 File: /dras20/astca/testlmt01.dbf (138)

 Block: 12               Offsets:    0 to  511           Dba:0x2280000c

------------------------------------------------------------------------

 23020000 2280000c aa35c797 00080104 c59e0000 00000000 00000000 00000000

 00000000 00000004 00000200 0a9c0000 00000003 0000004b 00000080 228001d4

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

最后我们来看一个MSSM的实例:

因为是9i,所以system表空间就是MSSM

6unlimited undo segment header,其实就是系统回滚段的段头,段头类型为0x0e

SQL> select HEADER_FILE,HEADER_BLOCK from dba_segments where segment_name='SYSTEM';

 

HEADER_FILE HEADER_BLOCK

----------- ------------

          1            9

 

BBED> set file 1

        FILE#           1

 

BBED> set block 9

        BLOCK#          9

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 9                Offsets:    0 to  511           Dba:0x00400009

------------------------------------------------------------------------

 0e020000 00400009 aa340432 00080104 cc3f0000 00000000 00000000 00000000

 00000000 00000006 0000002f 10200000 00000001 00000006 00000008 00400017

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

7MSSM里的unlimited data segment header,即大家从dba_segmentsselect出来的MSSM下的"段头",段头类型为0x10

SQL> select HEADER_FILE,HEADER_BLOCK from dba_segments where segment_name='OBJ$';

 

HEADER_FILE HEADER_BLOCK

----------- ------------

          1          121

 

BBED> set file 1

        FILE#           1

 

BBED> set block 121

        BLOCK#          121

 

BBED> map /v

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 121                                   Dba:0x00400079

------------------------------------------------------------

 Unlimited Data Segment Header

 

 struct kcbh, 20 bytes                      @0      

    ub1 type_kcbh                           @0      

    ......省略显示部分内容

    ub2 spare3_kcbh                         @18     

 

 struct ktech, 72 bytes                     @20     

    ub4 spare1_ktech                        @20     

    ......省略显示部分内容

    ub4 flag_ktech                          @88     

 

 struct ktemh, 16 bytes                     @92     

    ub4 count_ktemh                         @92     

    ub4 next_ktemh                          @96     

    ub4 obj_ktemh                           @100    

    ub4 flag_ktemh                          @104    

 

 struct ktetb[19], 152 bytes                @108    

    ub4 ktetbdba                            @108    

    ub4 ktetbnbk                            @112    

 

......省略显示部分内容

 ub4 tailchk                                @8188   

 

BBED> set offset 96

        OFFSET          96

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 121              Offsets:   96 to  607           Dba:0x00400079

------------------------------------------------------------------------

 00000000 00000012 40000000 0040007a 00000007 00401169 00000008 004011f9

 00000008 00401309 00000008 00401661 00000008 00402049 00000008 00403191

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

BBED> set offset 0

        OFFSET          0

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 121              Offsets:    0 to  511           Dba:0x00400079

------------------------------------------------------------------------

 10020000 00400079 aa2de25f 00080104 e69d0000 00000000 00000000 00000000

 00000000 00000013 000001ff 10200000 00000012 00000014 00000080 0040d91d

 ......省略显示部分内容

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

Kostas Hairopoulos曾经问我如何找到extent map header,我理解他的意思是问我如何找到extent map block,朋友们能从我上文中找到定位extent map header的方法吗?

Leave a comment