Initially immediate
This is the default when neither initially immediate nor initially deferred has been specified.
The constraint is checked after each SQL statement.
create table init_immediate (
id number primary key initially immediate,
data varchar2(50)
);
Initially deferred
The constraint is checked when a transaction ends.
drop table init_immediate;
create table init_immediate (
id number primary key initially deferred,
data varchar2(50) not null initially deferred
);
insert into init_immediate values ( null, 'one');
insert into init_immediate values ( 3, null);
insert into init_immediate values ( 8, 'eight');
insert into init_immediate values ( 3, 'two');
update init_immediate set id = 1 where data = 'one';
update init_immediate set id = 2 where data = 'two';
update init_immediate set data = 'three' where id = 3;
commit;
It will be OK.
ORA-02447
A not deferrable constraint cannot be set to initially deferred,
it raises an
ORA-02447: cannot defer a constraint that is not deferrable which seems logical:
create table no_no_ora_02447 (
id number primary key not deferrable initially deferred,
data varchar2(50)
);
Deferrable constraint
create table cons_deferrable_pk_tab (
a number,
b varchar2(10),
c number not null deferrable,
d date,
primary key (a, b) deferrable
);
create table cons_deferrable_fk_tab (
z,
y,
x varchar2(10),
foreign key (z,y) references cons_deferrable_pk_tab deferrable
);
Now we insert data to the table will fails, because reference table has not been inserted data yet.
insert into cons_deferrable_fk_tab values (1, 'one', 'foo');
ORA-02291: 整合性制約(ZOLO.SYS_C005382)に違反しました - 親キーがありません
set constraints all deferred
And now the constraints are deferred, so we can insert data which still not inserted to the reference table.
insert into cons_deferrable_fk_tab values (1, 'one', 'foo');
Though commit will fail.
set constraints [Oracle SQL]
set constraint[s] all { immediate | deferred };
set constraint[s] constraint-name-1 [, constraint-name-n ...] { immediate | deferred };
分享到:
相关推荐
DataGrid里面的执行分页删除 向数据库插入多条记录
Li-Rich Vapor Transport Equilibration Temperature Dependence of Surface Composition of Initially Congruent LiNbO3 Crystal
Unlike Windows search "Everything" initially displays every file and folder on your computer (hence the name "Everything"). You type in a search filter to limit what files and folders are displayed....
latex直接处理中文书签会生成乱码。经此处理,可以正确生成中文书签。>>latex file; >>gbk2uni file; >>latex file即可。
Language, previously as Mathematica, in different fields: initially as an undergraduate, doing differential equations homework as a freshman, nuclear structure calculations, as a graduate student in ...
DB2删除⼤数据量表⽅法 DB2不⽀持truncate语句... 效率很快 第⼆种: 在建表时加选项not logged initially ,当清空表时通过alter table [name] activate not logged initially with empty table 。 我采⽤的是第⼀种。
Understanding SOA with Web service主要是通过web服务来阐述SOA架构原理与方法,是当今一种相对主流的实现SOA架构的方式,很有启发,拿出来与大家共享一下!
第三章\code-3+第三章\code-3+第三章\code-3+第三章\code-3
SSCERuntime-ENU-x64.msi
WS_DISABLED Creates a window that is initially disabled. WS_DLGFRAME Creates a window with a double border but no title. WS_GROUP Specifies the first control of a group of controls in which the user...
The student may not initially be able to fully appreciate the concepts described here, but should be able to do so by the end of the course. The specifics of the E-R, relational, and object-oriented ...
people tend to generate initially. They reflect untold redesign and recoding as developers have struggled for greater reuse and flexibility in their software. Design patterns capture these solutions ...
Editor Android simple generic text editor. The app is available from F-Droid and here This is a very simple generic text ...initially be opened read only, long touch on the display or touch the ed
Aris Open Project is initially designed for Aris Launcher, a terminal launcher where you use your Android with commands. The fundamental idea of Aris Launcher is to expand the capability of data ...
Constructs an instance. The file offset is initially unknown.
This project aims to eventually replace a project I did a LONG time ago called letmeparty.com. I initially did it in a very comical attempt at making money. It did not do that at all. It is a site ...
JMS was initially developed to provide a standard Java API for the established messaging products that already existed. Since then many more messaging products have been developed. JMS provides a ...
Initially, it was dedicated to our international students on short-term student-exchange projects. At a later stage, we learned that a textbook on an introduction to finance, written in simple ...
android-obd-reader NOTICE I am no longer involved in any way with OBD and related activities, so don't expect my feedback on issues, pull-requests and most of all, ...Initially, it was more of an Andr
Use the word “Abstract” as the ‎ title, in 12-point Times, boldface type, centered relative ‎ to the column, initially capitalized. The abstract is to be ‎ in 10-point, single-spaced...