: Flashback 기능 (Flashback Version Query, Flashback Transaction Query, Flashback Table ) 을 위해
과거 Oracle Database 10g 에서는 Undo Tablespace 를 사용했던 반면,
11g 의 Flashback Data Archive 는 임의의 Tablespace 에 히스토리
데이터를 저장함으로써 보존 기간에 관련한 불필요한 제약 사항을 제거 하였습니다.
1. Create the flashback data archive
SQL> create smallfile tablespace fla_tbs1 datafile '/u01/data/IIGNF/fla_tbs01.dbf' size 10m reuse autoextend on
2 next 640k maxsize 32767m nologging extent management local segment space management auto ;
Tablespace created.
SQL> alter user hr identified by hr account unlock ;
User altered.
SQL> grant flashback archive administer to hr ;
Grant succeeded.
h3.2. FDA 생성
SQL> conn hr/hr
Connected.
SQL> create flashback archive fla1 tablespace fla_tbs1 quota 10m retention 1 year ;
Flashback archive created.
h3.3. Table 의 FDA 활성화
SQL> alter table hr.employees flashback archive fla1 ;
Table altered.
h3.4. FDA 확인
SQL> select employee_id, last_name, salary from hr.employees where last_name ='Fox';
EMPLOYEE_ID LAST_NAME SALARY
----------- --------------------------------------------------------------------------- ----------
170 Fox 9600
SQL> update hr.employees set salary = salary + 1000 where last_name ='Fox';
1 row updated.
SQL> commit ;
Commit complete.
SQL> update hr.employees set salary = salary + 1000 where last_name ='Fox';
1 row updated.
SQL> commit ;
Commit complete.
SQL> update hr.employees set salary = salary + 1000 where last_name ='Fox';
1 row updated.
SQL> commit ;
Commit complete.
SQL> select employee_id, last_name, salary from hr.employees where last_name ='Fox';
EMPLOYEE_ID LAST_NAME SALARY
----------- --------------------------------------------------------------------------- ----------
170 Fox 12600
-- 9600 + 1000 + 1000 + 1000 = 12600
SQL> select employee_id, last_name, salary
2 from hr.employees
3 as of timestamp
4 ( systimestamp - interval '10' minute )
5 where last_name ='Fox';
EMPLOYEE_ID LAST_NAME SALARY
----------- --------------------------------------------------------------------------- ----------
170 Fox 9600
SQL> update hr.employees
2 set salary =
3 ( select salary from hr.employees
4 as of timestamp ( systimestamp - interval '10' minute ) where last_name ='Fox')
5 where last_name ='Fox'
6 /
1 row updated.
SQL> col FLASHBACK_ARCHIVE_NAME for a30
SQL> select flashback_archive_name, create_time, status from dba_flashback_archive ;
FLASHBACK_ARCHIVE_NAME CREATE_TIME STATUS
------------------------------ --------------------------------------------------------------------------- ---------------------
FLA1 30-SEP-11 10.10.29.000000000 AM
SQL> col QUOTA_IN_MB for a20
SQL> col TABLESPACE_NAME for a30
SQL> select * from dba_flashback_archive_ts ;
FLASHBACK_ARCHIVE_NAME FLASHBACK_ARCHIVE# TABLESPACE_NAME QUOTA_IN_MB
------------------------------ ------------------ ------------------------------ --------------------
FLA1 1 FLA_TBS1 10
SQL> col table_name for a30
SQL> col OWNER_NAME for a20
SQL> col FLASHBACK_ARCHIVE_NAME for a20
SQL> col ARCHIVE_TABLE_NAME for a30
SQL> select * from dba_flashback_archive_tables ;
TABLE_NAME OWNER_NAME FLASHBACK_ARCHIVE_NA ARCHIVE_TABLE_NAME STATUS
------------------------------ -------------------- -------------------- ------------------------------ ------------------------
EMPLOYEES HR FLA1 SYS_FBA_HIST_73933 ENABLED
SQL> alter flashback archive fla1 purge before timestamp (systimestamp - interval '2' minute ) ;
Flashback archive altered.
SQL> alter flashback archive fla1 modify retention 2 year ;
Flashback archive altered.
SQL> alter table hr.employees no flashback archive ;
Table altered.
SQL> drop flashback archive fla1 ;
Flashback archive dropped.
h2.FDA 활성화 방법(요약)
h3.1. FDA 생성
-- SQL> create flashback archive fla1 tablespace tbs1 retention 2 year ;
( 2개 이상 생성 가능, Quota 설정 가능(1시간마다 체크함) )
h3.2. FDA 권한 부여
SQL> grant flashback archive administer to scott ;
or
SQL> grant flashback archive on fla1 to scott ;
h3.3. TABLE 의 FDA 지정
SQL> conn scott/tiger
SQL> alter table emp flashback archive fla1 ;
h3.FLASHBACK ARCHIVE ADMINISTER 권한
출처 : http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/process.htm#CNCPT1259
SQL> !ps -ef |grep fbda |grep -v grep
oracle 8716 1 0 10:10 ? 00:00:00 ora_fbda_IIGNF
*_FLASHBACK_ARCHIVE_TABLES