1.oracle误操作后恢复数据
首先,查询出误操作的那条sql的执行时间:
select vw.first_load_time,vw.sql_text from v$sqlarea vw where vw.sql_text='temp'
其中,temp 是误执行的sql语句,获取执行时间后,执行:
create table new_table as
select * from current_table as of timestamp to_timestamp('first_load_time','yyyy-mm-dd hh24:mi:ss')
其中new_table 是误操作前current_table 表的数据,current_table 是误操作后的表,“first_load_time”是误执行sql的时间。
2.整个数据表被删除
oracle在删除表时,没有直接清空表所占的块,只是做了可覆写标志,所以在未被重写前都可以恢复。
首先,在根据原数据表表名找到在回收站的名称(object_name)
select object_name,original_name,droptime from recyclebin where original_name=‘原数据表表名’;
然后,运行语句还原数据表
flashback table 被删除的表在回收站的名称 to before drop;
虽然这种方法把表找回来了,但是索引和约束都需要重新创建。