验证:basic compress 方式下,Rows inserted without using direct-path insert and updated rows are uncompressed.
1、创建表
----- append 方式插入
SQL> create table t compress basic tablespace test as select * From emp where 0=1;
表已创建。
----普通方式插入数据
SQL> create table t1 compress basic tablespace test as select * From emp where 0=1;
----用于插入append 插入
SQL> create table t2 tablespace test as select * From emp where 0=1;
-----普通方式插入数据
SQL> create table t3 tablespace test as select * From emp where 0=1;
COUNT(*)
----------
196608
2、插入数据
SQL> insert /*+ append */into t select * From test;
已创建196608行。
SQL> commit;
提交完成。
SQL> insert into t1 select * From test;
已创建196608行。
SQL> commit;
提交完成。
SQL> insert /*+ append */into t2 select * From test;
已创建196608行。
SQL> commit;
提交完成。
SQL> insert into t3 select * From test;
已创建196608行。
SQL> commit;
提交完成。
SQL> analyze table t compute statistics;
表已分析。
SQL> analyze table t1 compute statistics;
表已分析。
SQL> analyze table t2 compute statistics;
表已分析。
SQL> analyze table t3 compute statistics;
表已分析。
3、对比:
SQL> select table_name,blocks,compress_for From dba_tables where table_name in ('T','T1','T2','T3');TABLE_NAME BLOCKS COMPRESS_FOR
------------------------------ ---------- ------------
T 301 BASIC
T1 1126 BASIC
T2 1193
T3 1252
结论:使用append方式插入数据压缩效果比较好,虽然表是basic compress,如果是普通插入方式,那么基本和不压缩效果是一样的;
3、更新:
SQL> update t set sal=sal+1;
SQL> update t1 set sal=sal+1;
SQL> update t2 set sal=sal+1;
SQL> update t3 set sal=sal+1;
commit;
对四个表进行分析:
analyze table t compute statistics;
analyze table t1 compute statistics;
analyze table t2 compute statistics;
analyze table t3 compute statistics;
SQL> select table_name,blocks,compress_for From dba_tables where table_name in ('T','T1','T2','T3');
TABLE_NAME BLOCKS COMPRESS_FOR
------------------------------ ---------- ------------
T 1644 BASIC
T1 1126 BASIC
T2 1193
T3 1252
结论:basic 压缩方式的表,不适合做更新,否则占用空间会更大