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

oracle 闪回技术--闪回删除

时间:2016-04-13 20:15:51      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

1、查看是否启动闪回删除

SQL> show parameter recyclebin;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
recyclebin                           string      on

启动闪回

 

2、测试闪回删除的表:

创建两个一样的表,然后都删除,进行恢复。

SQL> create table edu.test_flash(id number(12),name varchar2(20));
 
Table created
 
SQL> insert into edu.test_flash values(1,1);
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> drop table edu.test_flash;
 
Table dropped
 
SQL> create table edu.test_flash(id number(12),name varchar2(20));
 
Table created
 
SQL> insert into edu.test_flash values(2,2);
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> drop table edu.test_flash;
 
Table dropped

查看回收站

SQL> select owner,original_name,object_name,ts_name,droptime from dba_recyclebin where owner=EDU;
 
OWNER                          ORIGINAL_NAME                    OBJECT_NAME                    TS_NAME                        DROPTIME
------------------------------ -------------------------------- ------------------------------ ------------------------------ -------------------
EDU                            TEST_FLASH                       BIN$MFwmGr6PC/LgUwEAAH94lA==$0 USERS                          2016-04-13:18:22:02
EDU                            TEST_FLASH                       BIN$MFwmGr6QC/LgUwEAAH94lA==$0 USERS                          2016-04-13:18:22:31

恢复删除的表

SQL> flashback table edu.test_flash to before drop;
 
Done

再次查看回收站

SQL> select owner,original_name,object_name,ts_name,droptime from dba_recyclebin where owner=EDU;
 
OWNER                          ORIGINAL_NAME                    OBJECT_NAME                    TS_NAME                        DROPTIME
------------------------------ -------------------------------- ------------------------------ ------------------------------ -------------------
EDU                            TEST_FLASH                       BIN$MFwmGr6PC/LgUwEAAH94lA==$0 USERS                          2016-04-13:18:22:02

发现直接按照名字进行闪回,闪回的是最后删除的表

如果需要指定闪回哪个表还可以执行:

flashback table "BIN$MFwmGr6PC/LgUwEAAH94lA==$0" to before drop rename to test_flash_2;

 

oracle 闪回技术--闪回删除

标签:

原文地址:http://www.cnblogs.com/huanhuanang/p/5388309.html

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