码迷,mamicode.com
首页 > 数据库 > 详细

oracle 11g drop table 后闪回

时间:2015-05-13 19:46:55      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

--初始化数据

drop table test purge;

create table test as select * from dba_objects;
delete from test where object_id is null;
alter table test add constraint pk_test_object_id primary key(object_id);
create index ind_t_object_name on test(object_name);

--执行删除操作
drop table test;

select r.object_name,r.original_name,r.operation,r.type from recyclebin r;
OBJECT_NAME                     ORIGINAL_NAME       OPERATION TYPE
------------------------------- ------------------ --------  --------
BIN$FfQ1SQRoVJjgUAoKlg9C7A==$0  TEST                DROP      TABLE
BIN$FfQ1SQRnVJjgUAoKlg9C7A==$0  PK_TEST_OBJECT_ID   DROP      INDEX
BIN$FfQ1SQRmVJjgUAoKlg9C7A==$0  IND_T_OBJECT_NAME   DROP      INDEX

--生成闪回表的语句
select ‘flashback table ‘ || r.original_name || ‘ to before drop;‘ cc
  from recyclebin r
 where type = ‘TABLE‘;
CC
--------------------------------------
flashback table TEST to before drop;
 
--索引会被闪回,但名称会被改 
select ‘alter index  "‘ || r.object_name || ‘" rename to "‘ || 
       r.original_name || ‘" ;‘ ccc
  from recyclebin r
 where type = ‘INDEX‘;
CCC
---------------------------------------------------------------------------------
alter index  "BIN$FfQ1SQRmVJjgUAoKlg9C7A==$0" rename to "IND_T_OBJECT_NAME" ;
alter index  "BIN$FfQ1SQRnVJjgUAoKlg9C7A==$0" rename to "PK_TEST_OBJECT_ID" ;


最后执行:
flashback table TEST to before drop;
alter index  "BIN$FfQ1SQRiVJjgUAoKlg9C7A==$0" rename to "IND_T_OBJECT_NAME" ;
alter index  "BIN$FfQ1SQRjVJjgUAoKlg9C7A==$0" rename to "PK_TEST_OBJECT_ID" ;

oracle 11g drop table 后闪回

标签:

原文地址:http://blog.csdn.net/stevendbaguo/article/details/45696601

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!