note:
the constants
comp_for_query_high
,
comp_for_query_low
,
comp_for_archive_high
, and
comp_for_archive_low
are used only in the context of exadata, specifically the feature,
exadata hybrid columnar compression (ehcc) which offers higher
compression ratios for direct path loaded data. for more information,
see the
oracle exadata storage server online documentation library.
more info:
----------------------------------------------------
test examples:
sql> alter table ct2 move compress;
#看来这个操作不一定产生真正的压缩表。table altered.
sql> select rowid, a.* from ct2 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasaqaafaaaaeraaa 1513
aaaaaa1513
sql> select dbms_compression.get_compression_type('gan', 'ct2', 'aaasaqaafaaaaeraaa') from dual;
dbms_compression.get_compression_type('gan','ct2','aaasaqaafaaaaeraaa')
-----------------------------------------------------------------------
1
sql> create table ct2_1 compress as select * from ct2;
table created.
sql> select rowid,a.* from ct2_1 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasaraafaaaacraaa 1513
aaaaaa1513
sql> select dbms_compression.get_compression_type('gan', 'ct2_1', 'aaasaraafaaaacraaa') from dual;
dbms_compression.get_compression_type('gan','ct2_1','aaasaraafaaaacraaa')
-------------------------------------------------------------------------
1
sql> insert into ct2_1 select * from ct2_1;
262144 rows created.
sql> /
524288 rows created.
sql> commit;
commit complete.
sql> select rowid,a.* from ct2_1 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasaraafaaaacraaa 1513
aaaaaa1513
sql> select dbms_compression.get_compression_type('gan', 'ct2_1', 'aaasaraafaaaacraaa') from dual;
dbms_compression.get_compression_type('gan','ct2_1','aaasaraafaaaacraaa')
-------------------------------------------------------------------------
1
sql> alter table ct2_1 move compress;
table altered.
sql> alter system switch logfile;
system altered.
sql> select rowid,a.* from ct2_1 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasasaafaaaa caaa 1034
aaaaaa1034
sql> select dbms_compression.get_compression_type('gan', 'ct2_1', 'aaasasaafaaaa caaa') from dual;
dbms_compression.get_compression_type('gan','ct2_1','aaasasaafaaaa caaa')
-------------------------------------------------------------------------
2
终于产生了一个olt compress类型的压缩表。再来产生一个query high类型的压缩表看看:sql> create table ct1 compress for query high as select * from tabx;
table created.
sql> select count(*) from ct1;
count(*)
----------
8192
sql> select rowid from ct1 where rownum<2;
rowid
------------------
aaar/qaafaaaacjaaa
sql> select rowid from tabx where rownum<2;
rowid
------------------
aaar/paafaaaacdaaa
sql> select dbms_compression.get_compression_type('gan', 'ct1', 'aaar/qaafaaaacjaaa') from dual;
dbms_compression.get_compression_type('gan','ct1','aaar/qaafaaaacjaaa')
-----------------------------------------------------------------------
4
sql> select dbms_compression.get_compression_type('gan', 'tabx', 'aaar/paafaaaacdaaa') from dual;
dbms_compression.get_compression_type('gan','tabx','aaar/paafaaaacdaaa')
------------------------------------------------------------------------
1
query low类型的压缩表:sql> create table ct8 compress for query low as select * from tabx;
table created.
sql> select rowid,a.* from ct8 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasataafaaaacraaa 1513
aaaaaa1513
sql> select dbms_compression.get_compression_type('gan', 'ct8', 'aaasataafaaaacraaa') from dual;
dbms_compression.get_compression_type('gan','ct8','aaasataafaaaacraaa')
-----------------------------------------------------------------------
8
archive high类型压缩表:sql> create table ct16 compress for archive high as select * from tabx;
table created.
sql> select rowid,a.* from ct16 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasauaafaaaac7aaa 1
aaaaaa1
sql> select dbms_compression.get_compression_type('gan', 'ct16', 'aaasauaafaaaac7aaa') from dual;
dbms_compression.get_compression_type('gan','ct16','aaasauaafaaaac7aaa')
------------------------------------------------------------------------
16
archive low类型压缩表:sql> create table ct32 compress for archive low as select * from tabx;
table created.
sql> select rowid,a.* from ct16 a where rownum<2;
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasauaafaaaac7aaa 1
aaaaaa1
sql> c/16/32
1* select rowid,a.* from ct32 a where rownum<2
sql> /
rowid a
------------------ ----------
b
--------------------------------------------------------------------------------
aaasavaafaaaaddaaa 1
aaaaaa1
sql> select dbms_compression.get_compression_type('gan', 'ct32', 'aaasavaafaaaaddaaa') from dual;
dbms_compression.get_compression_type('gan','ct32','aaasavaafaaaaddaaa')
------------------------------------------------------------------------
32