日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Oracle PL/SQL之Flashback Table与外键约束

發布時間:2025/7/14 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle PL/SQL之Flashback Table与外键约束 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我們知道 Flashback Table可以把drop掉的表從回收站里恢復回來,但是并不是關于該表的所有東西都能被Flashback回來,比如外鍵約束。

duzz$scott@orcl>create table d(deptno number primary key, deptname varchar2(20)); Table created. Elapsed: 00:00:00.28 duzz$scott@orcl>create table e(empno number primary key, ename varchar2(20), deptno number, constraint fk_dept foreign key (deptno) references d(deptno)); Table created. Elapsed: 00:00:00.39 duzz$scott@orcl>select * from d; DEPTNO DEPTNAME ---------- ----------- 10 IT 20 HR Elapsed: 00:00:00.03 duzz$scott@orcl>select * from e; EMPNO ENAME DEPTNO ---------- ------------- ---------- 1 KING 10 2 HARI 20 Elapsed: 00:00:00.00 duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E'); CONSTRAINT_NAME CON TABLE_NAME -------------------- --- ------------- SYS_C005553 P D SYS_C005554 P E FK_DEPT R E Elapsed: 00:00:00.00 duzz$scott@orcl>insert into e values(2,'COTT',10); insert into e values(2,'COTT',10) * ERROR at line 1: ORA-00001: unique constraint (SCOTT.SYS_C005554) violated Elapsed: 00:00:00.01 duzz$scott@orcl>insert into e values(3,'ING',55); insert into e values(3,'ING',55) * ERROR at line 1: ORA-02291: integrity constraint (SCOTT.FK_DEPT) violated - parent key not found Elapsed: 00:00:00.01 duzz$scott@orcl>drop table e; Table dropped. Elapsed: 00:00:00.09 duzz$scott@orcl>flashback table e to before drop; Flashback complete. Elapsed: 00:00:00.10 duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E'); CONSTRAINT_NAME CON TABLE_NAME -------------------- --- --------------- SYS_C005553 P D BIN$MzYoteesSWeEWRlJ P E Afkfcg==$0 Elapsed: 00:00:00.00 duzz$scott@orcl>insert into e values(2,'COTT',10); insert into e values(2,'COTT',10) * ERROR at line 1: ORA-00001: unique constraint (SCOTT.BIN$MzYoteesSWeEWRlJAfkfcg==$0) violated Elapsed: 00:00:00.01 duzz$scott@orcl>insert into e values(3,'ING',55); 1 row created. Elapsed: 00:00:00.00 duzz$scott@orcl>


除此之外,帶有細粒度審計(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

?

轉載于:https://www.cnblogs.com/zlja/archive/2011/08/25/2449075.html

總結

以上是生活随笔為你收集整理的Oracle PL/SQL之Flashback Table与外键约束的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。