2012-08-30

use total recall instead of triggers


http://www.oracle.com/technetwork/database/storage/total-recall-whitepaper-171749.pdf



CREATE FLASHBACK ARCHIVE fda1
TABLESPACE tbs1
RETENTION 5 YEAR;
This creates a new flashback data archive called ‘fda1’ on tablespace tbs1 with a retention policy
of 5 years. Since ‘QUOTA’ is not specified, the default setting of  ‘UNLIMITED’ is used




. Enable Flashback Data Archive on the desired tables.
ALTER TABLE EMPLOYEES FLASHBACK ARCHIVE fda1;
The EMPLOYEES table is now enabled for Flashback Data Archive, and its history data will be
stored in the flashback data archive ‘fda1’. When the first DML operation occurs, the internal
history table is created in ‘fda1’.



Flashback Data Archive provides seamless access to the historical data using the ‘AS OF’ or
‘VERSIONS BETWEEN’ SQL constructs. You can query for the state of any row in the tracked
table as far back as your specified retention period.
The following is an example for querying the salary details for the employee with id=193 on June
1, 2007:
SELECT last_name, first_name, salary
FROM EMPLOYEES
AS OF TIMESTAMP TO_TIMESTAMP(‘2007-06-01 00:00:00’,’YYYY-MM-DD HH24:MI:SS’)
WHERE employee_id=193;

Niciun comentariu:

Trimiteți un comentariu