11G新特性:FLASHBACK ARCHIVE - 01
閃回資料歸檔(FLASHBACK ARCHIVE)與UNDO表空間是沒有任何關係的,並且與flashback logs(開啟資料庫閃回生成的日誌)也無關。
閃回資料歸檔需要單獨為其建立相應的表空間(falshback tablespace)用於儲存對指定表修改的歷史資料。
下面演示針對DML操作的閃回查詢
建立FLASHBACK ARCHIVE
SQL>
create flashback archive default tbs_archive01
2
tablespace tbs_ht02
3
retention 1 day;
Flashback archive created.
查詢ligle.t01表資料
SQL>
col owner for a10
SQL> col object_name for a20
SQL> col object_type for a20
SQL> select owner,object_id,object_name,object_type from ligle.t01 where
wner='SCOTT'
OWNER OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- ---------- --------------------
-------------------
SCOTT 75334 PK_DEPT INDEX
SCOTT 75333 DEPT TABLE
SCOTT 75335 EMP TABLE
SCOTT 75336 PK_EMP INDEX
SCOTT 75337 BONUS TABLE
SCOTT 75338 SALGRADE TABLE
刪除一條資料
SQL>
delete from t01 where object_id=75334;
1 row deleted.
SQL> commit;
Commit complete.
再次查詢ligle.t01表資料
SQL>
select owner,object_id,object_name,object_type from ligle.t01 where
wner='SCOTT';
OWNER OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- ---------- -------------------- --------------------
SCOTT 75333 DEPT TABLE
SCOTT 75335 EMP TABLE
SCOTT 75336 PK_EMP INDEX
SCOTT 75337 BONUS TABLE
SCOTT 75338 SALGRADE TABLE
可以發現OBJECT_ID為75334的資料已被刪除。
透過FLASHBACK ARCHIVE查詢過去某時刻該表的資料:
SQL>
select owner,object_id,object_name,object_type from t01 as of timestamp
(systimestamp-interval '10' minute)
where wner='SCOTT';
OWNER OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- ---------- -------------------- --------------------
SCOTT
75334 PK_DEPT INDEX
SCOTT 75333 DEPT TABLE
SCOTT 75335 EMP TABLE
SCOTT 75336 PK_EMP INDEX
SCOTT 75337 BONUS TABLE
SCOTT 75338 SALGRADE TABLE
6 rows selected.
我們知道,在Oracle 11g以前,透過閃回查詢也可以查出過去某時刻的資料狀態(該方法的前提是UNDO表空間必須還存在該表被修改時的undo資料,否則將會報ORA-01555),那麼比較細心的朋友會發現,在上面的閃迴歸檔查詢中是不是也是用的UNDO資料呢?
可以透過切換當前的undo表空間來實驗下:
SQL>
conn /as sysdba
SQL> create undo tablespace UNDOTBS2 datafile
'/soft/oradata/horizon/undotbs02.dbf' size 10M;
SQL> alter system set undo_tablespace='UNDOTBS2';
SQL> conn ligle/ligle
Connected.
SQL> select owner,object_id,object_name,object_type from t01 as of timestamp
(systimestamp-interval '20' minute)
where wner='SCOTT';
OWNER OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- ---------- -------------------- --------------------
SCOTT 75334 PK_DEPT INDEX
SCOTT 75333 DEPT TABLE
SCOTT 75335 EMP TABLE
SCOTT 75336 PK_EMP INDEX
SCOTT 75337 BONUS TABLE
SCOTT 75338 SALGRADE TABLE
至此,可以明白,在當前UNDO表空間已被切換的情況下,依然可以查詢到過去某時刻的表資料狀態,所以可以證明FLASHBACK ARCHIVE與UNDO表空間是沒有關係的。
透過FLASHBACK ARCHIVE恢復表資料到某時刻:
SQL>
alter table t01 enable row movement;
Table altered.
SQL> flashback table t01 to timestamp
(systimestamp - interval '40' minute);
Flashback complete.
SQL> select owner,object_id,object_name,object_type from t01 where
wner='SCOTT';
OWNER OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- ---------- -------------------- --------------------
SCOTT 75333 DEPT TABLE
SCOTT 75335 EMP TABLE
SCOTT 75336 PK_EMP INDEX
SCOTT 75337 BONUS TABLE
SCOTT 75338 SALGRADE TABLE
SCOTT
75334 PK_DEPT INDEX
6 rows selected.
透過建立FLASHBACK ARCHIVE表空間來儲存指定表的變更歷史資料,避免了對UNDO表空間的過度依賴。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25834554/viewspace-710834/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 11G新特性:FLASHBACK ARCHIVEHive
- 11G新特性:FLASHBACK ARCHIVE – 02Hive
- 11G Flashback Data Archive新特性的研究Hive
- oracle 11g 新特性 Flashback Data Archive 說明OracleHive
- Oracle 11g新特性--閃回資料歸檔(flashback data archive)[zt]OracleHive
- oracle11g flashback archive feature新特性OracleHive
- 【FLASHBACK】Oracle flashback data archive 介紹OracleHive
- 11g feature: Flashback Data Archive Guide. (Doc ID 470199.1)HiveGUIIDE
- Oracle Flashback Data ArchiveOracleHive
- Flashback Data Archive RequirementsHiveUIREM
- Flashback Data Archive原理詳解Hive
- flashback drop/query/table/database/archiveDatabaseHive
- Flashback Data Archive (Oracle Total Recall)HiveOracle
- 11G flashback data archive 導致產生大量歸檔日誌Hive
- 【ORACLE新特性】11G 分割槽新特性Oracle
- (轉)oracle10g新特性之 flashbackOracle
- 10G新特性筆記之FLASHBACK筆記
- Oracle 11g 新特性Oracle
- 11g data guard 新特性
- 11g新特性--active dataguard
- oracle 11g 的新特性Oracle
- oracle flashback特性(2.1)--Flashback Table之RECYCLEBINOracle
- oracle flashback特性(3.2)--Flashback Database操作示例OracleDatabase
- How To Using Flashback Data Archive (Oracle Total Recall)HiveOracle
- 閃回資料歸檔-- Flashback Data ArchiveHive
- Oracle Flashback Archive——Oracle閃迴歸檔(上)OracleHive
- Oracle Flashback Archive——Oracle閃迴歸檔(中)OracleHive
- Oracle Flashback Archive——Oracle閃迴歸檔(下)OracleHive
- Playing with Flashback Data Archive on 11GR2Hive
- [20131017]11G下truncate的新特性.txt
- 11g新特性:Pending Statistics
- Oracle 11g 新特性簡介Oracle
- Oracle 11g 新特性之DRCPOracle
- 11g 新特性—— Active Database DuplicationDatabase
- Oracle 11g新特性:Result CacheOracle
- 11g新特性--result caching
- Oracle 11g 新特性(轉載)Oracle
- Oracle 11g新特性之SecureFilesOracle