6.Flashback Drop语法 SQL> FLASHBACK TABLE ft_1 TO BEFORE DROP; SQL> FLASHBACK TABLE "BIN$Z6gzDCWg7hfgQAB/AQAROQ==$0" TO BEFORE DROP; 上面两种方法都可以实现找回被删除表的功能。第一种方法是恢复到最后一次被删除的状态;第二种方法则可以对回收站中具体的一个对象进行闪回,用于一张表被多次删除后的恢复场景。
7.Flashback Drop闪回删除功能实践 (1).创建测试表ft_1 sys@ora11g> conn secooler/secooler Connected. secooler@ora11g> create table ft_1 as select * from all_objects;
Table created.
secooler@ora11g> select table_name from user_tables where table_name = 'FT_1';
TABLE_NAME ------------------------------ FT_1
(2).模拟drop掉ft_1表 secooler@ora11g> drop table ft_1;
Table dropped.
(3).查看回收站,这里看到ft_1表已经在回收站中了 secooler@ora11g> show recyclebin; ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME ---------------- ------------------------------ ------------ ------------------- FT_1 BIN$vXtL504BE5vgQMKQt8Bnug==$0 TABLE 2012-04-12:20:14:24
(4).演示一下查询功能 secooler@ora11g> select count(*) from "BIN$vXtL504BE5vgQMKQt8Bnug==$0";
COUNT(*) ---------- 71256
(5).闪回被drop掉的表 secooler@ora11g> flashback table ft_1 to before drop;
Flashback complete.
secooler@ora11g> select table_name from user_tables where table_name = 'FT_1';
TABLE_NAME ------------------------------ FT_1
这里在能确认回收站中哪个是要恢复的表时,也可以使用下面的命令进行恢复。 secooler@ora11g> drop table ft_1;
Table dropped.
secooler@ora11g> show recyclebin; ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME ---------------- ------------------------------ ------------ ------------------- FT_1 BIN$vXtL504IE5vgQMKQt8Bnug==$0 TABLE 2012-04-12:20:18:35
secooler@ora11g> flashback table "BIN$vXtL504IE5vgQMKQt8Bnug==$0" to before drop;
Flashback complete.
secooler@ora11g> select table_name from user_tables where table_name = 'FT_1';