Deferred Constraint Check
Two ways to accomplish such goal:
1. Constraints are created deferrable. Alter session set constraints = deferred.
create table p(
p_id number primary key);
create table c(
c_id number primary key,
p_id number
);
alter table c add constraint pid_fk foreign key (p_id) references p(p_id) deferrable;
table C altered.
alter session SET CONSTRAINTS = DEFERRED;
session SET altered.
begin
insert into c values(1,1);
insert into p values(1);
commit;
end;
anonymous block completed.
SELECT * FROM C;
C_ID P_ID
------- -------
1 1
2. Constraints are created initially deferred deferrable.
alter table c drop constraint pid_fk;
table C altered.
TRUNCATE TABLE P;
TRUNCATE TABLE C;
table P truncated.
table C truncated.
alter table c add constraint pid_fk foreign key (p_id) references p(p_id) INITIALLY DEFERRED deferrable;
table C altered.
In the other session:
BEGIN
INSERT INTO C VALUES(1,1);
INSERT INTO P VALUES(1);
COMMIT;
END;
anonymous block completed
PS: alter session set constraints = immediate makes initially deferred deferrable constraint checks violation immediately after each statement. Hence, the constraint is not deferred any more.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-774004/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- constraint deferrable immediate checkAI
- 使用deferred constraint 解決“先有蛋還是先有雞的問題”AI
- not null constraint和check constriant的問題及分析NullAI
- jQuery DeferredjQuery
- ConstraintAI
- jQuery 的deferred物件jQuery物件
- jQuery的Deferred物件概述jQuery物件
- initially immediate 與 initially deferred
- 約束CONSTRAINTAI
- constraint約束AI
- Unused&ConstraintAI
- Unity的Deferred ShadingUnity
- jQuery的deferred物件詳解jQuery物件
- onclick="return check()" 和 onclick="check()" 區別
- deferred中done和then的區別
- 熟練使用使用jQuery Promise (Deferred)jQueryPromise
- 約束的DEFERRABLE and DEFERRED特性
- constraint=constraints?AI
- Could not resolve com.android.support.constraint:constraint-layout:1.1.3AndroidAI
- jQuery中的Deferred詳解和使用jQuery
- jQuery原始碼解析Deferred非同步物件jQuery原始碼非同步物件
- Will attempt to recover by breaking constraintAI
- CONSTRAINT的用法舉例AI
- Constraint deferrable特性研究AI
- Deferring Constraint ChecksAI
- jQuery中的Deferred-詳解和使用jQuery
- 阮一峰:jQuery的deferred物件詳解jQuery物件
- Oracle 11g的Deferred Segment CreationOracle
- MySQL——約束(constraint)詳解MySqlAI
- 討論關於Constraint statesAI
- check_document_position
- type check例題
- WITH CHECK OPTION 詳解
- Using the WITH CHECK OPTION
- Check database status in RACDatabase
- [Oracle Script] check userOracle
- [Oracle Script] check latchOracle
- Prerequisite check "CheckActiveFilesAndExecutables" failedUIAI