日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2025/7/14 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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与外键约束的全部內容,希望文章能夠幫你解決所遇到的問題。

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