日期:2014-05-17  浏览次数:20798 次

在drop 和flashback table前后,主键和外键 是否还有效果
dept表中的 deptno 是pk 所在列, 同时在emp表上的deptno列,有外键,并且和dept 的deptno 存在关联关系,
而在emp 的empno上边,存在emp表自己的主键,

现在 DROP TABLE emp;
FLASHBACK TABLE emp TO BEFORE DROP; 到底 emp 的pk 和fk 哪一个约束依旧有效?

INSERT INTO emp VALUES (2,COTT 10);
INSERT INTO emp VALUES (3,ING 55);


这是 047中间的一个考题
In the DEPT table, DEPTNO is the PRIMARY KEY.
In the EMP table, EMPNO is the PRIMARY KEY and DEPTNO is the FOREIGN KEY
referencing the DEPTNO column in the DEPT table.
What would be the outcome of the following statements executed in the given
sequence?
DROP TABLE emp;
FLASHBACK TABLE emp TO BEFORE DROP;
INSERT INTO emp VALUES (2,COTT 10);
INSERT INTO emp VALUES (3,ING 55);

dept表的数据
deptno
10
20

emp 表的数据
empno ename deptno
1 king 10
2 hari 20


D. Only the second INSERT statement would succeed because all the constraints
except referential integrity constraints that reference other tables are
retrieved automatically after the table is flashed back.
Answer: D

有些不解


 



------解决方案--------------------
pk有效,fk無效
------解决方案--------------------
最主要的
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.

会重新建立外键