• Flashback Data Archive ( Oracle Total Recall ) introduced in 11g


    Flashback Data Archive feature is part of Oracle Total Recall technology. Flashback Data Archive feature lets you to track changes made in any number of tables for any given retention time. The retention time can be some days or months or years.

    Flashback data archives retain historical data for the time duration specified using the RETENTIONparameter. Historical data can be queried using the Flashback Query AS OF clause. Archived historic data that has aged beyond the specified retention period is automatically purged.

    This feature is supported only Oracle 11g Enterprise Edition. It is not available in Standard or Express editions.

    Lets see an example.

    Step 1:- Create Flashback data archive tablespace.

    1. SQL> select * from v$version;
    2. BANNER
    3. --------------------------------------------------------------------------------
    4. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    5. PL/SQL Release 11.2.0.4.0 - Production
    6. CORE 11.2.0.4.0 Production
    7. TNS for Linux: Version 11.2.0.4.0 - Production
    8. NLSRTL Version 11.2.0.4.0 - Production
    9. SQL> create tablespace FB_Storage datafile '/u01/app/oracle11g/oradata/DB11/datafile/fdstore.dbf'
    10. 2 size 100m autoextend on segment space management auto;
    11. Tablespace created.

    Step 2:- Create Flashback Archive

    1. SQL> create flashback archive default FB_Arch1 tablespace FB_Storage quota 1g retention 1 year;
    2. Flashback archive created.

    Step 3:- Turn on Flashback archive for tables you want to track.

    For Example to enable flashback archive for table Scott.emp

    (i) Grant Flashback archive privilege

    1. SQL> grant flashback archive on fb_arch1 to scott;
    2. Grant succeeded.
    3. SQL> connect scott/tiger
    4. Connected.

    (ii) Enable flashback archive for table

    1. SQL> alter table emp flashback archive;
    2. Table altered.

    Step 4:- Flashback Example.

    Suppose a user has deleted rows from emp by giving a delete statement like this

    1. SQL> set time on
    2. 19:57:32 SQL> select * from emp;
    3. DEPTNO DNAME LOC
    4. ---------- -------------- -------------
    5. 20 RESEARCH DALLAS
    6. 30 SALES CHICAGO
    7. 40 OPERATIONS BOSTON
    8. 19:57:56 SQL>
    9. 19:57:59 SQL>
    10. 19:57:59 SQL>
    11. 19:57:59 SQL>
    12. 19:57:59 SQL> delete from emp where deptno=30;
    13. 1 row deleted.
    14. 19:58:25 SQL> commit;
    15. Commit complete.

    To View the state of table emp 10 minutes before

    1. 19:58:29 SQL> select * from emp as of timestamp sysdate - 10 / (24*60);
    2. DEPTNO DNAME LOC
    3. ---------- -------------- -------------
    4. 10 ACCOUNTING NEW YORK
    5. 20 RESEARCH DALLAS
    6. 30 SALES CHICAGO
    7. 40 OPERATIONS BOSTON

    Versions Query (11gR2 only) (To see what changes are made to Emp No. 7902 between last 15 minutes

    1. 22:18:34 SQL> select * from emp versions between
    2. timestamp sysdate- 15 /(24*60) and sysdate
    3. where empno=7902;




  • 相关阅读:
    Dev GridControl 小结3
    一个web应用的诞生(9)--回到用户
    一个web应用的诞生(8)--博文发布
    一个web应用的诞生(7)--结构调整
    一个web应用的诞生(6)--用户账户
    一个web应用的诞生(5)--数据表单
    一个web应用的诞生(4)--数据存储
    一个web应用的诞生(3)--美化一下
    一个web应用的诞生(2)--使用模板
    一个web应用的诞生(1)--初识flask
  • 原文地址:https://www.cnblogs.com/haoxiaoyu/p/47d098cb7377f8b527330feb93d63e93.html
Copyright © 2020-2023  润新知