需求背景
准备删库撤退,可惜当场抓住,记录闪回过程,以便下次跑路。
表数据恢复
第一种方法
查询删除之前表的数据,导出再做插入操作。
select * from tablename as of timestamp to_timestamp('2020-02-02 02:02:02','yyyy-mm-dd hh24:mi:ss') where condition = 'xxx';
第二种方法
直接闪回表数据。
Flashback Table实际是通过Flashback Query将表中数据进行了一次删除、插入操作,因此ROWID也会发生变化。
ORA-08189: 因为未启用行移动功能, 不能闪回表.
alter table tablename enable row movement; --开启行移动
flashback table tablename to timestamp to_timestamp('2020-02-02 02:02:02','yyyy-mm-dd hh24:mi:ss');
alter table tablename disable row movement; --关闭行移动
表结构恢复
查询删除表
select object_name,
original_name,
partition_name,
type,
ts_name,
createtime,
droptime
from recyclebin;
恢复删除表
flashback table tablename to before drop;