# 关于 9iR2 的 compress table 的研究

http://otn.oracle.com/oramag/oracle/04-mar/o24tech_data.html

SQL> create table test1(a varchar2(20),b varchar2(20),c varchar2(20)) compress;

SQL> select TABLESPACE_NAME ,EXTENT_ID ,blocks from dba_extents where segment_name = 'TEST1';

TABLESPACE_NAME EXTENT_ID BLOCKS
------------------------------ ---------- ----------
USERS 0 8

SQL> select file_id,block_id from dba_extents where segment_name = 'TEST1';

FILE_ID BLOCK_ID
---------- ----------
11 769

SQL> insert /*+ append */ into test1 select 'AAAAAAAAAAAAAAAAAAAA','BBBBBBBBBBBBBBBBBBBB','CCCCCCCCCCCCCCCCCCCC' from dba_objects where rownum < 1001;

1000 rows created.

SQL> commit;

Commit complete.

SQL> alter system dump datafile 11 block min 769 block max 771;

System altered.

trace 部分内容

===============
tsiz: 0x1f88
hsiz: 0x5ce
bdba: 0x02c00302
76543210
flag=-0------
ntab=2
nrow=724
frre=-1
fsbo=0x5ce
fseo=0x1127
avsp=0xd
tosp=0xd
r0_9ir2=0x0
mec_kdbh9ir2=0x1
r1_9ir2=0x0
76543210
flag_9ir2=-------C
fcls_9ir2[4]={ 0 32768 32768 32768 }
0x1e: pti[0] nrow=1 offs=0
0x22: pti[1] nrow=723 offs=1
0x26: pri[0] offs=0x1f46
0x28: pri[1] offs=0x1f41
0x2a: pri[2] offs=0x1f3c
0x2c: pri[3] offs=0x1f37

x5b6: pri[712] offs=0x115e
0x5b8: pri[713] offs=0x1159
0x5ba: pri[714] offs=0x1154
0x5bc: pri[715] offs=0x114f
0x5be: pri[716] offs=0x114a
0x5c0: pri[717] offs=0x1145
0x5c2: pri[718] offs=0x1140
0x5c4: pri[719] offs=0x113b
0x5c6: pri[720] offs=0x1136
0x5c8: pri[721] offs=0x1131
0x5ca: pri[722] offs=0x112c
0x5cc: pri[723] offs=0x1127 总记录条数724条，每条消耗5字节存储
block_row_dump:
tab 0, row 0, @0x1f46
tl: 66 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 02 d3 03 dc 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 dc 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 dc 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43

tab 1, row 0, @0x1f41
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00 这里的5个字节就是实际存储内容，03 表示压缩了3个字段,估计这里最后00表示指针指向第一个存储了完全数据的 ROW 0
tab 1, row 1, @0x1f3c
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00
tab 1, row 2, @0x1f37
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00
tab 1, row 3, @0x1f32
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00
tab 1, row 4, @0x1f2d
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00
tab 1, row 5, @0x1f28
tl: 5 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
col 1: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 2: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 2c 00 01 03 00
tab 1, row 6, @0x1f23

SQL> truncate table test1;

Table truncated.

SQL> conn test/test
Connected.
SQL> insert /*+ append */ into test1 select rownum,'BBBBBBBBBBBBBBBBBBBB','CCCCCCCCCCCCCCCCCCCC' from dba_objects where rownum < 1001;

1000 rows created.

SQL> commit;

Commit complete.

SQL> alter system dump datafile 11 block min 769 block max 771;

System altered.

===============
tsiz: 0x1f88
hsiz: 0x5b2
bdba: 0x02c00302
76543210
flag=-0------
ntab=2
nrow=709
frre=-1
fsbo=0x5b2
fseo=0x6e3
avsp=0xc5
tosp=0xc5
r0_9ir2=0x0
mec_kdbh9ir2=0x1
r1_9ir2=0x0
76543210
flag_9ir2=------OC
fcls_9ir2[3]={ 0 32768 32768 }
perm_9ir2[3]={ 2 0 1 }

0x20: pti[0] nrow=1 offs=0
0x24: pti[1] nrow=708 offs=1
0x28: pri[0] offs=0x1f5b
0x2a: pri[1] offs=0x1f54
0x2c: pri[2] offs=0x1f4d
0x2e: pri[3] offs=0x1f46
0x30: pri[4] offs=0x1f3f
0x32: pri[5] offs=0x1f38
0x34: pri[6] offs=0x1f31
0x36: pri[7] offs=0x1f2a
0x38: pri[8] offs=0x1f23

x25c: pri[282] offs=0x1571
0x25e: pri[283] offs=0x1568
0x260: pri[284] offs=0x155f
0x262: pri[285] offs=0x1556
0x264: pri[286] offs=0x154d
0x266: pri[287] offs=0x1544
0x268: pri[288] offs=0x153b
0x26a: pri[289] offs=0x1532
0x26c: pri[290] offs=0x1529
0x26e: pri[291] offs=0x1520
0x270: pri[292] offs=0x1516
block_row_dump:
tab 0, row 0, @0x1f5b
tl: 45 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 01 24 02 dc 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 dc 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
tab 1, row 0, @0x1f52
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 30 39
bindmp: 2c 00 02 02 00 cb 37 30 39 我们注意这里的02表示压缩2字段，本来的插入的rownum对应数据字典中表创建顺序最前的字段被存储在最末尾
tab 1, row 1, @0x1f49
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 30
bindmp: 2c 00 02 02 00 cb 37 31 30
tab 1, row 2, @0x1f40
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 31
bindmp: 2c 00 02 02 00 cb 37 31 31
tab 1, row 3, @0x1f37
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 32
bindmp: 2c 00 02 02 00 cb 37 31 32
tab 1, row 4, @0x1f2e
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 33
bindmp: 2c 00 02 02 00 cb 37 31 33
tab 1, row 5, @0x1f25
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 34
bindmp: 2c 00 02 02 00 cb 37 31 34
tab 1, row 6, @0x1f1c
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 35
bindmp: 2c 00 02 02 00 cb 37 31 35
tab 1, row 7, @0x1f13
tl: 9 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 3] 37 31 36

SQL> drop table test1;

Table dropped.

SQL> create table test1 (a varchar2(20),b varchar2(20), c varchar2(20),d varchar2(10)) compress;

Table created.

SQL> insert /*+ append */ into test1 select rownum,'BBBBBBBBBBBBBBBBBBBB','CCCCCCCCCCCCCCCCCCCC','DDDDDD' from dba_objects where rownum < 1001;

1000 rows created.

SQL> commit;

Commit complete.

SQL> select file_id,block_id from dba_extents where segment_name = 'TEST1';

FILE_ID BLOCK_ID
---------- ----------
11 769

SQL> conn test/test
Connected.
SQL> alter system dump datafile 11 block min 769 block max 771;

System altered.

===============
tsiz: 0x1f88
hsiz: 0x5d4
bdba: 0x02c00302
76543210
flag=-0------
ntab=2
nrow=725
frre=-1
fsbo=0x5d4
fseo=0x64c
avsp=0xc
tosp=0xc
r0_9ir2=0x0
mec_kdbh9ir2=0x1
r1_9ir2=0x0
76543210
flag_9ir2=------OC
fcls_9ir2[4]={ 0 32768 32768 32768 }
perm_9ir2[4]={ 3 0 1 2 }

0x22: pti[0] nrow=1 offs=0
0x26: pti[1] nrow=724 offs=1
0x2a: pri[0] offs=0x1f54
0x2c: pri[1] offs=0x1f4d
0x2e: pri[2] offs=0x1f46
0x30: pri[3] offs=0x1f3f
0x32: pri[4] offs=0x1f38
0x34: pri[5] offs=0x1f31
0x36: pri[6] offs=0x1f2a

0x244: pri[269] offs=0x15df
0x246: pri[270] offs=0x15d6
0x248: pri[271] offs=0x15cd
0x24a: pri[272] offs=0x15c4
0x24c: pri[273] offs=0x15bb
0x24e: pri[274] offs=0x15b2
0x250: pri[275] offs=0x15a9
0x252: pri[276] offs=0x159f
block_row_dump:
tab 0, row 0, @0x1f54
tl: 52 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 6] 44 44 44 44 44 44
bindmp: 01 14 03 dc 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 dc 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 ce 44 44 44 44 44 44
tab 1, row 0, @0x1f4b
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 6] 44 44 44 44 44 44
col 3: [ 3] 37 32 35
bindmp: 2c 00 02 03 00 cb 37 32 35
tab 1, row 1, @0x1f42
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 6] 44 44 44 44 44 44
col 3: [ 3] 37 32 36
bindmp: 2c 00 02 03 00 cb 37 32 36
tab 1, row 2, @0x1f39
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 6] 44 44 44 44 44 44
col 3: [ 3] 37 32 37
bindmp: 2c 00 02 03 00 cb 37 32 37
tab 1, row 3, @0x1f30
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 6] 44 44 44 44 44 44
col 3: [ 3] 37 32 38
bindmp: 2c 00 02 03 00 cb 37 32 38

SQL> truncate table test1;

Table truncated.

SQL> conn test/test
Connected.
SQL> insert /*+ append */ into test1 select rownum,'BBBBBBBBBBBBBBBBBBBB','CCCCCCCCCCCCCCCCCCCC',rownum+1 from dba_objects where rownum < 1001;

1000 rows created.

SQL> commit;

Commit complete.

SQL> alter system dump datafile 11 block min 769 block max 771;

System altered.

===============
tsiz: 0x1f88
hsiz: 0x46e
bdba: 0x02c00302
76543210
flag=-0------
ntab=2
nrow=547
frre=-1
fsbo=0x46e
fseo=0x477
avsp=0x9
tosp=0x9
r0_9ir2=0x0
mec_kdbh9ir2=0x1
r1_9ir2=0x0
76543210
flag_9ir2=------OC
fcls_9ir2[3]={ 0 32768 32768 }
perm_9ir2[4]={ 2 0 1 3 }

0x20: pti[0] nrow=1 offs=0
0x24: pti[1] nrow=546 offs=1
0x28: pri[0] offs=0x1f5b
0x2a: pri[1] offs=0x1f52
0x2c: pri[2] offs=0x1f49
0x2e: pri[3] offs=0x1f40
0x30: pri[4] offs=0x1f37
0x32: pri[5] offs=0x1f2e
0x34: pri[6] offs=0x1f25

x464: pri[542] offs=0x4ab
0x466: pri[543] offs=0x49e
0x468: pri[544] offs=0x491
0x46a: pri[545] offs=0x484
0x46c: pri[546] offs=0x477
block_row_dump:
tab 0, row 0, @0x1f5b
tl: 45 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
bindmp: 02 47 02 dc 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 dc 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 4
3 43 43 43
tab 1, row 0, @0x1f52
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 1] 31
col 3: [ 1] 32
bindmp: 2c 00 03 02 00 c9 31 c9 32
tab 1, row 1, @0x1f49
tl: 9 fb: --H-FL-- lb: 0x0 cc: 4
col 0: [20] 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
col 1: [20] 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43
col 2: [ 1] 32
col 3: [ 1] 33

bindmp后面部分为各无法压缩的个列的值。这些列与数据字典中列的映射关系由block header 的 perm_9ir2[4]={ 2 0 1 3 } 部分说明

• 本文已收录于以下专栏：

## create table 节约成本中重要的属性 compress 详解

Usually, the application developer is responsible for designing the elements of an application, incl...
• shushugood
• 2012年09月13日 13:05
• 4731

## 11GR2 Advanced Compress之OLTP Table Compress的研究

• e_wsq
• 2012年04月01日 18:47
• 386

## Oracle基本表压缩（Basic Table Compression）

• yangning5850
• 2013年07月12日 21:24
• 2430

## SQL注入研究

• iuhxq
• 2004年09月08日 08:42
• 1596

## 关于XML的研究

$File_Read = fileopen($Xml_Src_File)$File_Write = fileopen($Xml_UTF8_File, 138)filewrite(\$File_Write...
• lw35888894
• 2009年10月16日 22:13
• 430

## 产品包装测试方法

• u013761220
• 2014年03月21日 11:22
• 586

## ALTER TABLE...MOVE 相关使用方法

1.  The ALTER TABLE...MOVE statement enables you to relocate data of a non-partitioned table or of a...
• rudymatrix
• 2009年12月15日 16:59
• 13755

## oracle basic compress

1、创建表       ----- append 方式插入 SQL> create table t compress  basic tablespace test  as  select * ...
• wll_1017
• 2014年04月10日 17:50
• 789

## resuse space

Reusespace 简介：The user tablespace has been allocated more space ,we need to reusethe free space to ...
• chichimanman
• 2014年08月18日 10:55
• 494

## OCP-1Z0-053-V12.02-256题

256.Sales details are being stored on a daily basis in the SALES_2007 table. A large amount of data ...
• rlhua
• 2013年11月07日 21:28
• 5041

举报原因： 您举报文章：关于 9iR2 的 compress table 的研究 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)