Oracle误删表的恢复

来源:互联网 发布:域名被墙跳转技术 编辑:程序博客网 时间:2024/06/06 07:16

利用ORACLE闪回机制,将删除的表闪回回来(原文:http://www.cnblogs.com/huangzhen/archive/2012/02/23/2364340.html)

找到回收站里删掉的表

select * from user_recyclebin where DROPTIME >'2012-02-22 00:00:00'; 

 

在闪之前, 但删除的表,如果又重新创建了一样的表名,所以不能直接闪回,要先删除这些表, (如需删除冲突表,执行此以下查询结果内容中的sql语句) 

select 'drop table '||ORIGINAL_NAME||' cascade constraint;' from user_recyclebin where DROPTIME >'2010-02-08 09:00:00' and type = 'TABLE'; 

 

( 生成闪回表的语句  )

select 'flashback table '||ORIGINAL_NAME||' to before drop;' from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'TABLE'; 


(索引恢复)

select 'ALTER INDEX "'||OBJECT_NAME||'" rename to '||ORIGINAL_NAME||';'  from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'INDEX';


(触发器恢复)

select 'ALTER TRIGGER "'||OBJECT_NAME||'" rename to '||ORIGINAL_NAME||';'  from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'TRIGGER';

0 0