表空间和数据文件 实验二 段空间管理技术
9i前手动管理段,通过在段头分配自由列表(freelist)实现;9i中,引入自动段空间管理ASSM.ASSM是位图管理,有一级位图,二级位图等。一级位图记录每个使用了的块的状态,分4个:>75%,50%-75%,25%-50%和<25%,unformatted为未使用的。
一.查询表空间的区和段的管理方式:
SQL> select tablespace_name,extent_management,segment_space_management from dba_tablespaces;
TABLESPACE_NAME EXTENT_MAN SEGMEN
------------------------------ ---------- ------
SYSTEM LOCAL MANUAL
UNDOTBS1 LOCAL MANUAL
SYSAUX LOCAL AUTO
TEMP LOCAL MANUAL
USERS LOCAL AUTO
EXAMPLE LOCAL AUTO
PERFSTAT LOCAL AUTO
通过以上查询可以看到区间的管理方式是LOCAL,是本地管理的;段的管理有MANUAL和AUTO两种段管理方式。
二.对段进行跟踪
SQL> select file_id,extent_id,block_id,blocks from dba_extents
2 where segment_name='EMP5';
FILE_ID EXTENT_ID BLOCK_ID BLOCKS
---------- ---------- ---------- ----------
4 0 553 8
4 1 561 8
4 2 569 8
4 3 577 8
4 4 617 8
SQL> alter system dump datafile 4 block 553;
Start dump data blocks tsn: 4 file#: 4 minblk 553 maxblk 553
buffer tsn: 4 rdba: 0x01000229 (4/553)
scn: 0x0000.002347bb seq: 0x01 flg: 0x04 tail: 0x47bb2001
frmt: 0x02 chkval: 0x47eb type: 0x20=FIRST LEVEL BITMAP BLOCK
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x09BD2200 to 0x09BD4200
Dump of First Level Bitmap Block
--------------------------------
nbits : 4 nranges: 2 parent dba: 0x0100022a poffset: 0
unformatted: 12 total: 16 first useful block: 3
owning instance : 1
instance ownership changed at
Last successful Search
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 0
Extent Map Block Offset: 4294967295
First free datablock : 4
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Inc #: 0 Objd: 54226
HWM Flag: HWM Set
Highwater:: 0x0100022d ext#: 0 blk#: 4 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 4
mapblk 0x00000000 offset: 0
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x01000229 Length: 8 Offset: 0
0x01000231 Length: 8 Offset: 8
0:Metadata 1:Metadata 2:Metadata 3:FULL
4:unformatted 5:unformatted 6:unformatted 7:unformatted
8:unformatted 9:unformatted 10:unformatted 11:unformatted
12:unformatted 13:unformatted 14:unformatted 15:unformatted
--------------------------------------------------------
SQL> alter system dump datafile 4 block 554;
Start dump data blocks tsn: 4 file#: 4 minblk 554 maxblk 554
buffer tsn: 4 rdba: 0x0100022a (4/554)
scn: 0x0000.0023dbeb seq: 0x02 flg: 0x04 tail: 0xdbeb2102
frmt: 0x02 chkval: 0x54cd type: 0x21=SECOND LEVEL BITMAP BLOCK
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x09BD2200 to 0x09BD4200
Dump of Second Level Bitmap Block
number: 3 nfree: 3 ffree: 0 pdba: 0x0100022b
Inc #: 0 Objd: 54226
opcode:1
xid:
L1 Ranges :
--------------------------------------------------------
0x01000229 Free: 5 Inst: 1
0x01000239 Free: 5 Inst: 1
0x01000269 Free: 5 Inst: 1
--------------------------------------------------------
553是这个区间的第一个块,记录信息多,是FIRST LEVEL BITMAP BLOCK;554是这个区间中的紧邻553的一个块,是SECOND LEVEL BITMAP BLOCK。parent dba 是下一块的地址,parent dba: 0x0100022a 变为pdba: 0x0100022b。rdba是当前块的地址,这里由rdba: 0x01000229 (4/553)到rdba: 0x0100022a(4/554)。
L1 Ranges表示的是1级位图的地址范围,如0x01000229是其中一个一级位图。
删除EMP5的一个数值再来看块553的变化,未发现变化,又删除一些数据。
SQL> delete from scott.emp5 where empno<7844;
已删除11行。
SQL> alter system dump datafile 4 block 553;
仍未见到大的变化,可能是这个表中的删除数据还不能构成一个block的缘故吧。
后来又在表中插入1000条记录,然后再次跟踪,有变化。
SQL> begin
2 for i in 1 .. 1000 loop
3 insert into emp5(EMPNO) values(i+1000);
4 end loop;
5 commit;
6 end;
DBA Ranges :
0x01000229 Length: 8 Offset: 0
0x01000231 Length: 8 Offset: 8
此处要说明地址范围:0x01000229到0x01000231,8个块,8个地址。0x01000231-0x0100022=8
nbits : 4 nranges: 2 parent dba: 0x0100022a poffset: 0
unformatted: 8 total: 16 first useful block: 3
owning instance : 1
instance ownership changed at 01/03/2011 14:00:10
Last successful Search 01/03/2011 14:00:10
Freeness Status: nf1 0 nf2 0 nf3 0 nf4 3
Extent Map Block Offset: 4294967295
First free datablock : 4
Bitmap block lock opcode 0
Locker xid: : 0x0000.000.00000000
Inc #: 0 Objd: 54226
HWM Flag: HWM Set
Highwater:: 0x01000231 ext#: 0 blk#: 8 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 8
mapblk 0x00000000 offset: 0
--------------------------------------------------------
DBA Ranges :
--------------------------------------------------------
0x01000229 Length: 8 Offset: 0
0x01000231 Length: 8 Offset: 8
0:Metadata 1:Metadata 2:Metadata 3:FULL
4:75-100% free 5:75-100% free 6:FULL 7:75-100% free
8:unformatted 9:unformatted 10:unformatted 11:unformatted
12:unformatted 13:unformatted 14:unformatted 15:unformatted
--------------------------------------------------------
变化有:unformatted由12个下降到8个,full从1个变为了2个,有3个块有75-100% free,Highwater:: 0x0100022d ext#: 0 blk#: 4变为Highwater:: 0x01000231 ext#: 0 blk#: 8 。也就是说Highwater上升了,升了4个块(01000231-0100022d =4),从本区间的第4块到本区间的第8块(开始时第4块为第一块unformatted,而添加1000行后第8块为第一块unformatted)。
?为什么块3,6是full,而4,5却没有?是不是此处不是按顺序把块装满呢?应该是有对应关系的,对应的是固定的列,刚才添加的数据主要是对EMPNO这一列添加的。
select segment_name from dba_extents where tablespace_name='SYSTEM' and segmenttype=’TABLE’;
select file_id,block_id from dba_extents where segment_name='OLAP_OLEDB_FUNCTIONS_PUT';
但显示为空。想看看freelists是不是真的为0。因为这个是手动管理的段。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22528444/viewspace-683301/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22528444/viewspace-683301/