知識要點
- 閃回數據庫
- 閃回表
- 閃回查詢
閃回數據庫
使用閃回日誌。閃回需要關閉數據庫,只能用於特殊情況
創建flashback
sqlplus>shutdown immediate;
sqlplus>start mount;
sqlplus>alter system set db_recovery_file_dest_size=1G;
sqlplus>alter system set db_recovery_file_dest=’/u01/app/oracle/’;
sqlplus>alter database flash_back on;
時間點閃回
sqlplus>shutdown immediate;
sqlplus>startup mount;
sqlplus>flashback database to timestamp to_timestamp(‘2017-07-04 14:30:00’,’yyyy-mm-dd hh24:mi:ss’);
還原點閃回
創建可靠還原點
sqlplus>create restore point b4 guarantee flashback database;
flashback database to restore point b4;
查詢可靠還原點
sqlplus>select * from v$restore_point;
閃回表
使用undo歷史記錄
1. 打開行移動
sqlplus>alter table scott.emp enable row movement;
2. 還原點閃回恢復
sqlplus>flashback table scott.emp to restore point b5;
3. 時間點閃回
sqlplus>flashback table scott.emp to timestamp to_timestamp(‘2017-07-04 15:05:32’,’yyyy-mm-dd hh24:mi:ss’);
閃回查詢
指定時間閃回
sqlplus>select * from scott.emp as of timestamp to_timestamp(‘2017-07-04 15:53:32’,’yyyy-mm-dd hh24:mi:ss’);
閃回版本查詢
sqlplus>select sal,versions_startscn,versions_endscn,versions_operation from scott.emp versions between scn minvalue and maxvalue where empno=7839;
sqlplus>select sal,versions_xid,versions_startscn,versions_endscn,versions_operation from scott.emp versions between timestamp sysdate-5/1440 and sysdate where empno=7839;
閃回事務查詢
sqlplus>select undo_sql from flashback_transaction_query;