创建constraint时的选项:not deferrable和deferrable
2012-02-01 16:26
274 查看
使用语法:not deferrable | deferrable [ initially { immediate | deferred } ]
not deferrable 是不可延迟,并且约束也无法更改为可延迟状态。约束会在每一句sql statement 之后都进行 check,不符合则 roll back
deferrable 是可延迟状态,在 deferrable 状态时又有2个选项,创建时缺省是initially immediate,即约束会在每一句sql statement 之后都进行 check,效果等同于not deferrable,但是可以修改延迟状态。
initially deferred 约束会在整个事务进行commit 时check,如果不符合则roll back
在deferrable状态下,可以通过set constraints修改 immediate或者deferred
The keyword indicating that the mode you are specifying should be applied to all constraints within the current transaction.
constraint
The name of a specific constraint of which you wish to set the mode.
DEFERRED
The keyword indicating that constraints (or a specific constraint) shouldn't be checked until the transaction reaches a COMMIT.
IMMEDIATE
The keyword indicating that constraints (or a specific constraint) should be checked at the end of each statement within a transaction.
The message returned when a constraint mode is set successfully.
ERROR: Constraint 'constraint' does not exist
The error returned if you attempt to change the mode of a constraint that does not exist.
Use of IMMEDIATE mode will force the checking of all constraints at the end of each statement within the transaction. In DEFERRED mode, constraints are not checked until a COMMIT command
is issued.
Note: PostgreSQL 7.1.x (the most current version as of the writing of this book) only supports the use of these modes with foreign key constraints, as both check and unique constraints are set to a constraint mode that is not affected by
this command.
not deferrable 是不可延迟,并且约束也无法更改为可延迟状态。约束会在每一句sql statement 之后都进行 check,不符合则 roll back
deferrable 是可延迟状态,在 deferrable 状态时又有2个选项,创建时缺省是initially immediate,即约束会在每一句sql statement 之后都进行 check,效果等同于not deferrable,但是可以修改延迟状态。
initially deferred 约束会在整个事务进行commit 时check,如果不符合则roll back
在deferrable状态下,可以通过set constraints修改 immediate或者deferred
Synopsis
SET CONSTRAINTS { ALL | constraint [,... ] } { DEFERRED | IMMEDIATE }
Parameters
ALLThe keyword indicating that the mode you are specifying should be applied to all constraints within the current transaction.
constraint
The name of a specific constraint of which you wish to set the mode.
DEFERRED
The keyword indicating that constraints (or a specific constraint) shouldn't be checked until the transaction reaches a COMMIT.
IMMEDIATE
The keyword indicating that constraints (or a specific constraint) should be checked at the end of each statement within a transaction.
Results
SET CONSTRAINTSThe message returned when a constraint mode is set successfully.
ERROR: Constraint 'constraint' does not exist
The error returned if you attempt to change the mode of a constraint that does not exist.
Description
Use the SET CONSTRAINTS command to set the constraint mode for all constraints or for a single constraint within the current transaction block. You can choose to set the constraint mode to either IMMEDIATE or DEFERRED.Use of IMMEDIATE mode will force the checking of all constraints at the end of each statement within the transaction. In DEFERRED mode, constraints are not checked until a COMMIT command
is issued.
Note: PostgreSQL 7.1.x (the most current version as of the writing of this book) only supports the use of these modes with foreign key constraints, as both check and unique constraints are set to a constraint mode that is not affected by
this command.
Example
The following example sets the constraint evaluation mode to IMMEDIATE for all constraints within the transaction:SET CONSTRAINTS ALL IMMEDIATE;
相关文章推荐
- Oracle创建Sequence时Order/NoOrder选项
- Android菜单详解(二)——创建并响应选项菜单
- java中使用$.ajax创建下拉选项
- WindowsMobile创建自定义对话框(多选项对话框)
- IDEA创建XML文件没有Spring Config选项
- 您对无法重新创建的表进行了更改或者启用了“阻止保存要求重新创建表的更改”选项
- 创建带子菜单的选项菜单
- C语言(Head First C)-4_3:创建小工具:命令行选项
- 安卓对话框之----创建带多选项列表的对话框
- Android菜单详解(二)——创建并响应选项菜单
- 用qtcreator创建工程时,没有Applications这个选项(Qt Gui应用)
- 创建CDS view 无法找到DDL source选项问题
- 不允许保存更改。您所做的更改要求删除并重新创建一下表。您对无法重新创建的表进行了更改或启用了“阻止保存要求重新创建表的更改”选项
- 其它内容选项----第二章:创建和管理内容
- GCC编译选项--创建与使用库
- Android菜单详解(二)——创建并响应选项菜单
- lucene索引_创建_域选项和lucene索引_的删除、更新.
- FTP 打开文件夹提示"该文件没有程序与之关联来执行该操作 请在控制面板的文件夹选项中创建关联
- Jenkins创建job时Check-out Strategy各个选项详细说明(含图)
- [导入]创建索引时指定索引选项的好处