oracle 约束:延迟 与 立即
来源:互联网 发布:西海岸新区知乎 编辑:程序博客网 时间:2024/04/29 16:31
文档地址:http://docs.oracle.com/cd/B19306_01/server.102/b14200/clauses002.htm#i1002273
constraint_state::=
Description of the illustrationconstraint_state.gif
constraint_state constraint_state
with bothinline and out-of-line specification. You can specify the clausesofconstraint_state
in any order,but you can specify each clause only once.
DEFERRABLEClause DEFERRABLE
andNOT
DEFERRABLE
parameters indicate whether or not, insubsequent transactions, constraint checking can be deferred untilthe end of the transaction using theSET
CONSTRAINT
(S
) statement. If you omit thisclause, then the default isNOT
DEFERRABLE
.
Specify
NOT
DEFERRABLE
to indicate that in subsequent transactionsyou cannot use theSET
CONSTRAINT
[S
] clause to defer checking ofthis constraint until the transaction is committed. The checking ofaNOT
DEFERRABLE
constraint can never bedeferred to the end of the transaction.If you declare a new constraint
NOT
DEFERRABLE
, then it must be valid at the time theCREATE
TABLE
orALTER
TABLE
statement is committed or the statement willfail.Specify
DEFERRABLE
toindicate that in subsequent transactions you can use theSET
CONSTRAINT
[S
] clause todefer checking of this constraint until after the transaction iscommitted. This setting in effect lets you disable the constrainttemporarily while making changes to the database that might violatethe constraint until all the changes arecomplete.
You cannot alter the deferrability of a constraint. That is,whether you specify either of these parameters, or make theconstraintNOT
DEFERRABLE
implicitly byspecifying neither of them, you cannot specify this clause in anALTER
TABLE
statement. You must drop theconstraint and re-create it.
See Also:
SET CONSTRAINT[S] for information on setting constraintchecking for a transaction
Oracle Database Administrator's Guide andOracle Database Concepts for more informationabout deferred constraints
"DEFERRABLE Constraint Examples"
Restriction on[NOT] DEFERRABLE
INITIALLYClause INITIALLY
clause establishes the defaultchecking behavior for constraints that areDEFERRABLE
.The INITIALLY
setting can be overridden by aSET
CONSTRAINT
(S
) statementin a subsequent transaction.
Specify
INITIALLY
IMMEDIATE
toindicate that Oracle should check this constraint at the end ofeach subsequent SQL statement. If you do not specifyINITIALLY
at all, then the default isINITIALLY
IMMEDIATE
.If you declare a new constraint
INITIALLY
IMMEDIATE
, then it must bevalid at the time theCREATE
TABLE
orALTER
TABLE
statement is committed or thestatement will fail.Specify
INITIALLY
DEFERRED
to indicate thatOracle should check this constraint at the end of subsequenttransactions.
This clause is not valid if you havedeclared the constraint to beNOT
DEFERRABLE
, because a NOT
DEFERRABLE
constraint is automaticallyINITIALLY
IMMEDIATE
and cannot ever beINITIALLY
DEFERRED
.
文档地址:http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10003.htm#SQLRF01703
SETCONSTRAINT[S]
Purpose
UsetheSET
CONSTRAINTS
statement to specify,for a particular transaction, whether a deferrable constraint ischecked following each DML statement or when the transaction iscommitted.
Prerequisites
To specify when a deferrable constraint is checked, you musthave SELECT
privilege on the table to which theconstraint is applied unless the table is in your schema.
Syntax
set_constraints::=
Description of the illustrationset_constraints.gif
Semantics
constraint
Specify the name of one or more integrityconstraints.
ALL
Specify ALL
to set all deferrable constraints forthis transaction.
IMMEDIATE
Specify IMMEDIATE
to indicate that theconditions specified by the deferrable constraint are checkedimmediately after each DML statement.
DEFERRED
Specify DEFERRED
to indicate that theconditions specified by the deferrable constraint are checked whenthe transaction is committed.
Note:
You can verify the success of deferrable constraints prior tocommitting them by issuing aSET
CONSTRAINTS
ALL
IMMEDIATE
statement.Examples
Setting Constraints:Examples
SET CONSTRAINTS ALL IMMEDIATE;
The following statement checks three deferred constraints whenthe transaction is committed. This example fails if the constraintswere specified to beNOT
DEFERRABLE
.
SET CONSTRAINTS emp_job_nn, emp_salary_min , hr.jhist_dept_fk@remote DEFERRED;
- oracle 约束:延迟 与 立即
- NHibernate延迟加载与立即加载
- NHibernate之延迟加载与立即加载
- Oracle可延迟约束Deferable的使用
- Oracle可延迟约束Deferable的使用
- Oracle可延迟约束Deferable的使用
- 九、NHibernate之延迟加载与立即加载
- NHibernate 延迟加载与立即加载 (第七篇)
- 约束延迟
- 延迟约束
- oracle约束与索引
- Oracle-主键约束、唯一约束与外键约束
- Oracle-主键约束、唯一约束与外键约束
- Oracle-主键约束、唯一约束与外键约束
- oracle--认识表与约束
- Masonry约束立即生效跟约束更新
- for循环内绑定事件的问题(立即执行与延迟执行)。
- 关于延迟约束
- 关于关联子查询--correlated subquery
- 转置多表INSERT语句
- oracle 下WITH CHECK OPTION用法
- oracle中rollup和cube的用法
- 一道Oracle面试年薪70W的DBA题目
- oracle 约束:延迟 与 立即
- 包含子查询的一条insert语句
- External Tables
- interval day to second和interval year to month数据类型
- Oracle的时区问题
- hibernate中的缓存机制
- oracle 迁移数据方案(定制数据库模板)
- 详解GROUPING函数
- MERGE的使用一些注意事项