Oracle OLTP表压缩技术

OLTP压缩

 

对于启用11g OLTP压缩特性的表而言,当发生INSERT时若块内部空间的阈值未达到则不作压缩,若INSERT后达到阈值则触发压缩,如上图所示。 该压缩一般与commit/rollback无关。

若存在多个字段,则可以共享使用符号表:

 

OLTP压缩1

 

 

表空间级别指定OLTP压缩:

create tablespace TablespaceName datafile ‘……..’  default COMPRESS FOR OLTP;

表级别指定压缩:

create table OLTPCOMP (t1 int,t2 varchar2(200))                    COMPRESS FOR OLTP;

 

将表修改为COMPRESS FOR OLTP 但对现有块不压缩

alter table TableName  COMPRESS FOR OLTP;

move并将表修改为COMPRESS FOR OLTP

alter table TableName MOVE COMPRESS FOR OLTP;

 

可以通过在线重定义在线修改为 压缩:

BEGIN
  DBMS_REDEFINITION.CAN_REDEF_TABLE('SH','SALES',DBMS_REDEFINITION.CONS_USE_PK);
END;
/

create table SALES_TMP compress for oltp as select * from SALES where 1=2;
alter table SALES_TMP add primary key(col1);

BEGIN
  DBMS_REDEFINITION.START_REDEF_TABLE(
    uname => 'SH', orig_table => 'SALES', int_table  => 'SALES_TMP',
    col_mapping => NULL, options_flag => DBMS_REDEFINITION.CONS_USE_PK);
END;
/

BEGIN
  DBMS_REDEFINITION.SYNC_INTERIM_TABLE('SH','SALES', 'SALES2');
END;
/


BEGIN
  DBMS_REDEFINITION.FINISH_REDEF_TABLE('SH','SALES', 'SALES2');
END;
/

drop table SALES_TMP;


 


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *