6.Flashback Drop語法 SQL> FLASHBACK TABLE ft_1 TO BEFORE DROP; SQL> FLASHBACK TABLE "BIN$Z6gzDCWg7hfgQAB/AQAROQ==$0" TO BEFORE DROP; 上面兩種方法都可以實現(xiàn)找回被刪除表的功能。第一種方法是恢復到最后一次被刪除的狀態(tài);第二種方法則可以對回收站中具體的一個對象進行閃回,用于一張表被多次刪除后的恢復場景。
7.Flashback Drop閃回刪除功能實踐 (1).創(chuàng)建測試表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';