oracle basic compress

验证: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;

SQL> select count(*)from test;
  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 压缩方式的表,不适合做更新,否则占用空间会更大

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值