Oracle 12c 新特性之 In-Database Archiving

        In-Database Archiving 允许我们把表内的数据设置为不活跃的状态(INACTIVE),我们可以通过更改会话状态来确定这些INACTIVE的数据是否可见,这个特性可用于历史数据的归档,把这些不可见的数据进行压缩,使用这个特性时,我们需要把表的ROW ARCHIVAL特性打开,通过在SESSION级别设置ROW ARCHIVAL VISIBILITY为ACTIVE或ALL,来确定这些数据是否可见,具体实例如下:

 

SQL> create table t(msg varchar2(20)) row archival;

Table created.

SQL> insert into t select 'aaaaaaaa' from dual;

1 row created.

SQL> insert into t select 'bbbbbbbb' from dual;

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t;

MSG

--------------- ---------------

aaaaaaaa

bbbbbbbb

SQL> col msg format a15

SQL> col ora_archive_state format a15

SQL> select msg,ora_archive_state from t;

MSG       ORA_ARCHIVE_STA

--------------- ---------------

aaaaaaaa  0

bbbbbbbb  0

SQL> update t setora_archive_state='1' where msg='aaaaaaaa';

1 row updated.

SQL> commit;

Commit complete.

SQL> select * from t;

MSG

---------------

bbbbbbbb

SQL> ##此时第一条记录是不可见的

SQL> alter session setrow archival visibility = all;

Session altered.

SQL> select * from t;

MSG

---------------

aaaaaaaa

bbbbbbbb

SQL> select msg,ora_archive_state from t;

MSG       ORA_ARCHIVE_STA

--------------- ---------------

aaaaaaaa  1

bbbbbbbb  0

SQL> alter session setrow archival visibility = active;

Session altered.

SQL> select msg,ora_archive_state from t;

MSG       ORA_ARCHIVE_STA

--------------- ---------------

bbbbbbbb  0

 


 

 

你可能感兴趣的:(Oracle 12c 新特性之 In-Database Archiving)