我們知道 Flashback Table可以把drop掉的表從資源回收筒裡恢複回來,但是並不是關於該表的所有東西都能被Flashback回來,比如外鍵約束。
duzz$scott@orcl>create table d(deptno number primary key, deptname varchar2(20));</p><p>Table created.</p><p>Elapsed: 00:00:00.28<br />duzz$scott@orcl>create table e(empno number primary key, ename varchar2(20), deptno number, constraint fk_dept foreign key (deptno) references d(deptno));</p><p>Table created.</p><p>Elapsed: 00:00:00.39<br />duzz$scott@orcl>select * from d;</p><p> DEPTNO DEPTNAME<br />---------- -----------<br /> 10 IT<br /> 20 HR</p><p>Elapsed: 00:00:00.03<br />duzz$scott@orcl>select * from e;</p><p> EMPNO ENAME DEPTNO<br />---------- ------------- ----------<br /> 1 KING 10<br /> 2 HARI 20</p><p>Elapsed: 00:00:00.00<br />duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E');</p><p>CONSTRAINT_NAME CON TABLE_NAME<br />-------------------- --- -------------<br />SYS_C005553 P D<br />SYS_C005554 P E<br />FK_DEPT R E</p><p>Elapsed: 00:00:00.00<br />duzz$scott@orcl>insert into e values(2,'COTT',10);<br />insert into e values(2,'COTT',10)<br />*<br />ERROR at line 1:<br />ORA-00001: unique constraint (SCOTT.SYS_C005554) violated</p><p>Elapsed: 00:00:00.01<br />duzz$scott@orcl>insert into e values(3,'ING',55);<br />insert into e values(3,'ING',55)<br />*<br />ERROR at line 1:<br />ORA-02291: integrity constraint (SCOTT.FK_DEPT) violated - parent key not found</p><p>Elapsed: 00:00:00.01<br />duzz$scott@orcl>drop table e;</p><p>Table dropped.</p><p>Elapsed: 00:00:00.09<br />duzz$scott@orcl>flashback table e to before drop;</p><p>Flashback complete.</p><p>Elapsed: 00:00:00.10<br />duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E');</p><p>CONSTRAINT_NAME CON TABLE_NAME<br />-------------------- --- ---------------<br />SYS_C005553 P D<br />BIN$MzYoteesSWeEWRlJ P E<br />Afkfcg==$0</p><p>Elapsed: 00:00:00.00<br />duzz$scott@orcl>insert into e values(2,'COTT',10);<br />insert into e values(2,'COTT',10)<br />*<br />ERROR at line 1:<br />ORA-00001: unique constraint (SCOTT.BIN$MzYoteesSWeEWRlJAfkfcg==$0) violated</p><p>Elapsed: 00:00:00.01<br />duzz$scott@orcl>insert into e values(3,'ING',55);</p><p>1 row created.</p><p>Elapsed: 00:00:00.00<br />duzz$scott@orcl><br />
除此之外,帶有細粒度審計(Fine-Grained Auditing )和虛擬專用資料庫策略(Virtual Private Database policies)的表也不可恢複的哦,請看Oracle官方的Flashback說明:
A table and all of its dependent objects (indexes, LOB segments, nested tables, triggers, constraints and so on) go into the recycle bin together, when you drop the table. Likewise, when you perform Flashback Drop, the objects are generally all retrieved together.
It is possible, however, that some dependent objects such as indexes may have been reclaimed due to space pressure. In such cases, the reclaimed dependent objects are not retrieved from the recycle bin.
Due to security concerns, tables which have Fine-Grained Auditing (FGA) and Virtual Private Database (VPD) policies defined over them are not protected by the recycle bin.
Partitioned index-organized tables are not protected by the recycle bin.
The recycle bin does not preserve referential constraints on a table (though other constraints will be preserved if possible). If a table had referential constraints before it was dropped (that is, placed in the recycle bin), then re-create any referential constraints after you retrieve the table from the recycle bin with Flashback Drop.
REF:
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/flashptr004.htm