|
也许大多数人都觉得没什么实际意义?那就当我无聊罢了
个人以为这个探究涉及到block内碎片的问题,pctused/pctfree 的问题……
再无聊一把,证明给你看:
SQL> create table t_row(a number, b varchar2(100));
Table created.
SQL> insert into t_row select rownum,rownum from t where rownum < 11;
10 rows created.
SQL> commit;
Commit complete.
SQL> exec show_space('t_row');
Free Blocks.............................1
Total Blocks............................16
Total Bytes.............................131072
Unused Blocks...........................14
Unused Bytes............................114688
Last Used Ext FileId....................3
Last Used Ext BlockId...................8738
Last Used Block.........................2
PL/SQL procedure successfully completed.
SQL> alter system dump datafile 3 block 8739;
System altered.
SQL> select a,rowid from t_row;
A ROWID
---------- ------------------
1 AAAGbpAADAAACIjAAA
2 AAAGbpAADAAACIjAAB ----我们看这条记录的 rowid ,AAB 表示 行号 0*64^2 + 0*64^1 + 1 = 1
3 AAAGbpAADAAACIjAAC
4 AAAGbpAADAAACIjAAD
5 AAAGbpAADAAACIjAAE
6 AAAGbpAADAAACIjAAF
7 AAAGbpAADAAACIjAAG
8 AAAGbpAADAAACIjAAH
9 AAAGbpAADAAACIjAAI
10 AAAGbpAADAAACIjAAJ
10 rows selected.
data_block_dump
===============
tsiz: 0x1fb8
hsiz: 0x26
pbl: 0x09826c44
bdba: 0x00c02223
flag=-----------
ntab=1
nrow=10
frre=-1
fsbo=0x26
fseo=0x1f67
avsp=0x1f38
tosp=0x1f38
0xe: pti[0] nrow=10 offs=0
0x12: pri[0] offs=0x1f67
0x14: pri[1] offs=0x1f6f ----我们看这条记录的 物理位置, pri[1] 表示 row 号,offs=0x1f6f表示物理位置
0x16: pri[2] offs=0x1f77
0x18: pri[3] offs=0x1f7f
0x1a: pri[4] offs=0x1f87
0x1c: pri[5] offs=0x1f8f
0x1e: pri[6] offs=0x1f97
0x20: pri[7] offs=0x1f9f
0x22: pri[8] offs=0x1fa7
0x24: pri[9] offs=0x1faf
block_row_dump:
tab 0, row 0, @0x1f67
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 1] 31
tab 0, row 1, @0x1f6f
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 03
col 1: [ 1] 32
tab 0, row 2, @0x1f77
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 04
col 1: [ 1] 33
tab 0, row 3, @0x1f7f
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 05
col 1: [ 1] 34
tab 0, row 4, @0x1f87
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 06
col 1: [ 1] 35
tab 0, row 5, @0x1f8f
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 07
col 1: [ 1] 36
tab 0, row 6, @0x1f97
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 08
col 1: [ 1] 37
tab 0, row 7, @0x1f9f
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 09
col 1: [ 1] 38
tab 0, row 8, @0x1fa7
tl: 8 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 0a
col 1: [ 1] 39
tab 0, row 9, @0x1faf
tl: 9 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 0b
col 1: [ 2] 31 30
end_of_block_dump
SQL> update t_row set b = 'WWWWWWWWWWW' where a = 2;
1 row updated.
SQL> commit;
Commit complete.
SQL> select a,rowid from t_row;
A ROWID
---------- ------------------
1 AAAGbpAADAAACIjAAA
2 AAAGbpAADAAACIjAAB ----rowid 没有发生改变
3 AAAGbpAADAAACIjAAC
4 AAAGbpAADAAACIjAAD
5 AAAGbpAADAAACIjAAE
6 AAAGbpAADAAACIjAAF
7 AAAGbpAADAAACIjAAG
8 AAAGbpAADAAACIjAAH
9 AAAGbpAADAAACIjAAI
10 AAAGbpAADAAACIjAAJ
10 rows selected.
SQL> alter system dump datafile 3 block 8739;
System altered.
SQL>
data_block_dump
===============
tsiz: 0x1fb8
hsiz: 0x26
pbl: 0x09826c44
bdba: 0x00c02223
flag=-----------
ntab=1
nrow=10
frre=-1
fsbo=0x26
fseo=0x1f55
avsp=0x1f2f
tosp=0x1f2f
0xe: pti[0] nrow=10 offs=0
0x12: pri[0] offs=0x1f67
0x14: pri[1] offs=0x1f55 --offs=0x1f55,物理位置已经发生变化,update 的时候由于原来的空间不足,被提升到了block的最上面
0x16: pri[2] offs=0x1f77
0x18: pri[3] offs=0x1f7f
0x1a: pri[4] offs=0x1f87
0x1c: pri[5] offs=0x1f8f
0x1e: pri[6] offs=0x1f97
0x20: pri[7] offs=0x1f9f
0x22: pri[8] offs=0x1fa7
0x24: pri[9] offs=0x1faf
block_row_dump:
tab 0, row 0, @0x1f67
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 02
col 1: [ 1] 31
tab 0, row 1, @0x1f55 物理位置发生变化
tl: 18 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 03
col 1: [11] 57 57 57 57 57 57 57 57 57 57 57 变化后的数据
tab 0, row 2, @0x1f77
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 04
col 1: [ 1] 33
tab 0, row 3, @0x1f7f
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 05
col 1: [ 1] 34
tab 0, row 4, @0x1f87
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 06
col 1: [ 1] 35
tab 0, row 5, @0x1f8f
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 07
col 1: [ 1] 36
tab 0, row 6, @0x1f97
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 08
col 1: [ 1] 37
tab 0, row 7, @0x1f9f
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 09
col 1: [ 1] 38
tab 0, row 8, @0x1fa7
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 0a
col 1: [ 1] 39
tab 0, row 9, @0x1faf
tl: 9 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 0b
col 1: [ 2] 31 30
end_of_block_dump |
|