Oracle flashback闪回用法实战详解

作者:分开不是尽头 | 创建时间: 2023-05-06
Flashback Database 功能与RMAN的不完全恢复有点类似, 可以把整个数据库回退到过去的某个时点的状态, 这个功能依赖于Flashback log 日志。 优点是比RMAN更快速和高效。因此Flashback Databas...
Oracle flashback闪回用法实战详解

操作方法

启动数据库到mount状态。

开启数据库flashback闪回查询,然后启动数据库到open状态。

创建flashback还原点 SQL>create restore point b4 guarantee flashback database;

解锁scott用户,删掉该用户的emp表; drop table emp purge;

关闭数据库,启动数据库到mount状态

在mount阶段闪回数据库到删除emp表之前的状态 SQL>flashback database to timestamp to_timestamp('2014-12-08 11:31:00','yyyy-mm-dd hh24:mi:ss');

启动数据库到readonly状态,查看emp表是否存在,此时发现emp已经回来了。 SQL>alter database open read only;

到shell终端下导出找回的表格。 $exp scott/tiger tables=emp file=emp.dmp

再次关闭数据库,然后启动到mount状态。

再次闪回数据库到删除emp表之后,关闭数据库之前。 SQL>flashback database to timestamp to_timestamp('2014-12-08 12:00:00'),'yyyy-mm-dd hh24:mi:ss'); 闪回之后使用resetlogs方式打开数据库。

查看scott下的emp表,不存在。

回到shell终端,导入emp表 $imp scott/tiger file=emp tables=emp

再次检查emp表。

温馨提示

删除表的时候注意一下大概的删除时间以便恢复的时候找准时间。
第一次恢复到误删除表格之前,导出emp表;然后恢复到闪回操作之前的时间点,保持数据一致性。
Flashback的缺陷就是在恢复过程必须关闭数据库。
点击展开全文

更多推荐