PlSQL DROP 表后找回表和数据

前端之家收集整理的这篇文章主要介绍了PlSQL DROP 表后找回表和数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. //利用ORACLE闪回机制,将删除的表闪回回来 找到回收站里删掉的表
  2. select * from user_recyclebin where DROPTIME >'2012-02-22 00:00:00';
  3.  
  4. //在闪之前, 但删除的表,如果又重新创建了一样的表名,所以不能直接闪回,要先//删除这些表, (如需删除冲突表,执行此以下查询结果内容中的sql语句)
  5. select 'drop table '||ORIGINAL_NAME||' cascade constraint;' from user_recyclebin where DROPTIME >'2010-02-08 09:00:00' and type = 'TABLE';
  6.  
  7. //( 生成闪回表的语句 )
  8. select 'flashback table '||ORIGINAL_NAME||' to before drop;' from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'TABLE';
  9.  
  10. //(索引恢复)
  11. select 'ALTER INDEX "'||OBJECT_NAME||'" rename to '||ORIGINAL_NAME||';' from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'INDEX';
  12.  
  13. //(触发器恢复)
  14. select 'ALTER TRIGGER "'||OBJECT_NAME||'" rename to '||ORIGINAL_NAME||';' from user_recyclebin where DROPTIME >'2012-02-22 17:00:00' and type = 'TRIGGER';

猜你在找的Oracle相关文章