11G新特性 -- flashback data archive(2)

创建Flashback Data Archive
用户需要授予dba或flashback archive administer系统特权。flashback archive administer系统特权包含:create flashback archive,alter flashback archive,drop flashback archive权利。

SQL> select * from dba_sys_privs where privilege like '%FLASH%';

GRANTEE                        PRIVILEGE                                ADM COM
------------------------------ ---------------------------------------- --- ---
SYS FLASHBACK ANY TABLE NO NO
DBA FLASHBACK ANY TABLE NO NO
SYS FLASHBACK ARCHIVE ADMINISTER NO NO
DBA FLASHBACK ARCHIVE ADMINISTER NO NO
MDSYS FLASHBACK ANY TABLE NO NO SQL> grant flashback archive administer to hr;
SQL> create tablespace flash_tbs datafile '/u01/app/oracle/oradata/yb/flash01.dbf' size 300m autoextend on next 30m maxsize 5g;
SQL> create flashback archive flash1 tablespace flash_tbs retention year;

创建Flashback Data Archive:

SQL> create tablespace tbs1 datafile '/u01/app/oracle/oradata/dbt/tbs101.dbf' size 2G;
SQL> create flashback archive default fla1 tablespace tbs1 quota 1g retention month;

修改Flashback Data Archive:

#设置默认的flashback data archive
SQL> alter flashback archive fla1 set default;
#flashback data archive 添加表空间
SQL> alter flashback archive fla1 add tablespace tbs2 quota1g;
SQL> alter flashback archive fla1 add tablespace tbs3;
#修改配额
SQL> alter flashback archive fla1 modify tablespace tbs3 quota 20G;
#修改期限
SQL> alter flashback archive fla1 modify retention year;
#移除一个表空间
SQL> alter flashback archive fla1 remove tablespace tbs2;
#purge历史数据
SQL> alter flashback archive fla1 purge all;
SQL> alter flashback archive fla1 purge before timestamp(systimestamp-inteval '' day);
SQL> alter flashback archive fla1 purge before scn ;

删除Flashback Data Archive:

SQL> drop flashback archive fla1;

开启、取消flashback data archive:
缺省情况下没有对表开启Flashback Data Archive

SQL> create table test1( name varchar2(),address varchar2()) flashback archive flash1;
SQL> select * from dba_flashback_archive_tables; TABLE_NAME OWNER_NAME FLASHBACK_ARCHIVE_NAME ARCHIVE_TABLE_NAME STATUS
------------------------- ------------------------- ------------------------------ ----------------------------------------------------- -------------
TEST1 HR FLASH1 SYS_FBA_HIST_106929 ENABLED SQL> create table test2( name varchar2(),address varchar2()) ;
SQL> alter table test2 flashback archive;
SQL> select * from dba_flashback_archive_tables; TABLE_NAME OWNER_NAME FLASHBACK_ARCHIVE_NAME ARCHIVE_TABLE_NAME STATUS
------------------------- ------------------------- ------------------------------ ----------------------------------------------------- -------------
TEST1 HR FLASH1 SYS_FBA_HIST_106929 ENABLED
TEST2 HR FLASH1 SYS_FBA_HIST_106930 ENABLED SQL> alter table test2 no flashback archive;
SQL> drop flashback archive flash1;

Flashback Data Archive开启对DDL的支持:
只支持以下DDL语句:
-alter table
-truncate table
-rename table
如果使用了不受支持的DDL语句,可以先用dbms_flashback_archive.disassociate_fba过程使得表和flashback data archive分离,DDL操作完成后使用dbms_flashback_archive.reassociate_fba重新关联

示例:

SQL> create table test01(id int,name varchar2(),job varchar2()) flashback archive fla1;

Table created.

SQL> insert into test01 values(,'hello','tec');

 row created.

SQL> commit;

Commit complete.

SQL> select to_char(systimestamp, 'YYYY-MM-DD HH24:MI:SS') FROM dual;

TO_CHAR(SYSTIMESTAM
-------------------
-- :: SQL> update test01 set job='dev' where id=; row updated. SQL> commit; Commit complete. SQL> select to_char(systimestamp, 'YYYY-MM-DD HH24:MI:SS') FROM dual; TO_CHAR(SYSTIMESTAM
-------------------
-- :: SQL> update test01 set job='dba' where id=; row updated. SQL> commit; Commit complete. SQL> select to_char(systimestamp, 'YYYY-MM-DD HH24:MI:SS') FROM dual; TO_CHAR(SYSTIMESTAM
-------------------
-- :: SQL> select * from test01; ID NAME JOB
---------- -------------------- --------------------
hello dba SQL> SELECT * FROM test01 AS OF TIMESTAMP TO_TIMESTAMP ('2015-11-03 10:06:04', 'YYYY-MM-DD HH24:MI:SS'); ID NAME JOB
---------- -------------------- --------------------
hello dev SQL>
上一篇:Android---用Wi-Fi来建立对等连接


下一篇:解决linux环境下qt groupbox 边框不显示问题