首先什么是段头?
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
0x
0x0e unlimited undo segment header
0x
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
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
1、datafile 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
......省略显示部分内容
00000000 00000000 00000000 00000059 00075445
<32 bytes per line>
2、bitmapped 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 aa
00000001 00000000 00000000 00000007 00000488 00000004 00000005 00000000
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
3、ASSM里的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 aa
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
这里Block 137、138、265、266、393、394也是L1 BMB。
4、ASSM里的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 aa
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
5、ASSM里的Pagetable segment header block,即大家从dba_segments里select出来的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:0x
------------------------------------------------------------------------
23020000
00000000 00000004 00000200
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
最后我们来看一个MSSM的实例:
因为是9i,所以system表空间就是MSSM。
6、unlimited 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 cc
00000000 00000006
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
7、MSSM里的unlimited data segment header,即大家从dba_segments里select出来的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
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 aa2de
00000000 00000013 000001ff 10200000 00000012 00000014 00000080 0040d91d
......省略显示部分内容
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
Leave a comment