知识要点
闪回数据库
创建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_operation from scott.emp versions between timestamp sysdate-5/1440 and sysdate where empno=7839;