您的位置:首页 > 数据库 > Oracle

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

2015-06-23 18:54 681 查看
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
RETENTION
parameter. 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.

SQL> select * from v$version;


BANNER

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

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

CORE    11.2.0.4.0      Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production


SQL> create tablespace FB_Storage datafile '/u01/app/oracle11g/oradata/DB11/datafile/fdstore.dbf'

2  size 100m autoextend on segment space management auto;


Tablespace created.

[/code]Step 2:- Create Flashback Archive

SQL> create flashback archive default FB_Arch1 tablespace FB_Storage quota 1g retention 1 year;


Flashback archive created.

[/code]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

SQL> grant flashback archive on fb_arch1 to scott;


Grant succeeded.


SQL> connect scott/tiger

Connected.

[/code](ii) Enable flashback archive for table

SQL> alter table emp flashback archive;


Table altered.

[/code]Step 4:- Flashback Example.

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

SQL> set time on


19:57:32 SQL> select  * from emp;


DEPTNO DNAME          LOC

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

20 RESEARCH       DALLAS

30 SALES          CHICAGO

40 OPERATIONS     BOSTON


19:57:56 SQL>

19:57:59 SQL>

19:57:59 SQL>

19:57:59 SQL>

19:57:59 SQL>delete from emp where deptno=30;


1 row deleted.


19:58:25 SQL> commit;


Commit complete.

[/code]To View the state of table emp 10 minutes before

19:58:29 SQL> select * from emp as of timestamp sysdate - 10 / (24*60);


DEPTNO DNAME          LOC

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

10 ACCOUNTING     NEW YORK

20 RESEARCH       DALLAS

30 SALES          CHICAGO

40 OPERATIONS     BOSTON

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

22:18:34 SQL> select * from emp versions between

timestamp sysdate- 15 /(24*60) and sysdate

where empno=7902;

[/code]

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: