当前位置:首页 > 数据库 > Oracle

oracle 闪回技术--闪回删除

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

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

启动闪回

 

2、测试闪回删除的表:

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

SQL>createtable edu.test_flash(id number(12),name varchar2(20));
 
Table created
 
SQL>insertinto edu.test_flash values(1,1);
 
1 row inserted
 
SQL>commit;
 
Commit complete
 
SQL>droptable edu.test_flash;
 
Table dropped
 
SQL>createtable edu.test_flash(id number(12),name varchar2(20));
 
Table created
 
SQL>insertinto edu.test_flash values(2,2);
 
1 row inserted
 
SQL>commit;
 
Commit complete
 
SQL>droptable 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;

 

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


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐