Flashback Restore Point(闪回还原点)
闪回还原点分两种,一种是Normal Restore Points(正常还原点),另一种是Guaranteed Restore Points(担保还原点)
正常还原点和担保还原点的信息都是保存在控制文件,区别在于正常还原点的信息如果不手动删除控制文件也会自动维护管理删除,而担保还原点如果不手动删除,控制文件是不会自动删除的,也就说只要设立了担保还原点没有手动删除,数据库就一定能恢复到那个还原点状态。如果担保还原点和Flashback Database一起使用,那么数据库就能闪回到担保还原点起和之后的任何时间点。
The database can retain up to 2048 restore point. Restore points are retained in the database for at least the number of days specified for the CONTROL_FILE_RECORD_KEEP_TIME
initialization parameter. The default value of that parameter is 7 days. Guaranteed restore points are retained in the database until explicitly dropped by the user.
正常还原点的使用
创建正常还原点
SQL>CREATE RESTORE POINT restore1;
查看flashback模式
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
执行闪回还原点
SQL> FLASHBACK database TO RESTORE POINT restore1; --mount状态下执行
删除还原点
SQL> drop restore point restore1;
Restore point dropped.
担保还原点的使用
创建担保还原点
SQL> CREATE RESTORE POINT restore2 GUARANTEE FLASHBACK DATABASE;
查询flashback模式
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
RESTORE POINT ONLY --没开启Flashback Database模式下
执行闪回还原点
SQL> FLASHBACK database TO RESTORE POINT restore2; --mount状态下执行
删除还原点
SQL>drop RESTORE POINT restore2;
11g还可以指定过去的scn或timestamp
CREATE RESTORE POINT res1 AS OF SCN 1229570;
CREATE RESTORE POINT res2 AS OF TIMESTAMP to_date('2013-10-10 23:12:12','YYYY-MM-DD HH24:MI');
用还原点闪回表
CREATE RESTORE POINT good_data; SELECT salary FROM employees WHERE employee_id = 108; SALARY
----------
12000 UPDATE employees SET salary = salary*10
WHERE employee_id = 108; SELECT salary FROM employees
WHERE employee_id = 108; SALARY
----------
120000 COMMIT;
ALTER TABLE employees ENABLE ROW MOVEMENT;
FLASHBACK TABLE employees TO RESTORE POINT good_data; SELECT salary FROM employees
WHERE employee_id = 108; SALARY
----------
12000