对误删的表记录,只要没有truncate语句,就可以根据事务的提交时间进行选择恢复,一般步骤有:
1、先从flashback_transaction_query视图里查询,视图提供了供查询用的表名称、事务提交时间、UNDO_SQL等字段。注意:11g查看到UNDO_SQL为空,是因为
Oracle11g禁用了supplemental
logging
开启后恢复正常:
alter database add supplemental log data;
SQL> alter database add supplemental log data;
如:select * from
flashback_transaction_query where table_name='TEST';
select
START_SCN,START_TIMESTAMP,COMMIT_SCN,COMMIT_TIMESTAMP,UNDO_CHANGE#,TABLE_NAME,TABLE_OWNER,UNDO_SQL
from flashback_transaction_query where table_name='EMP2' order by
COMMIT_TIMESTAMP desc
2、执行表记录恢复
一般先根据时间进行查询,查询语句模式为select * from tb as of
timestamp to_timestamp(time,'yyyy-mm-dd hh24:mi:ss'); tb指表名称,time指某个时间点
如select * from scott.test as of timestamp