SET CONSTRAINTS 中文man页面

系统
SET CONSTRAINTS 设置当前事务里的约束运算的特性。 在 IMMEDIATE 模式下,约束是在每条语句后面进行检查的。 在 DEFERRED 模式下,一直到事务提交时才检查约束。

NAME

SET CONSTRAINTS - 设置当前事务的约束模式

SYNOPSIS

SET CONSTRAINTS { ALL | name [, ...] } { DEFERRED | IMMEDIATE }

DESCRIPTION 描述

SET CONSTRAINTS 设置当前事务里的约束运算的特性。 在 IMMEDIATE 模式下,约束是在每条语句后面进行检查的。 在 DEFERRED 模式下,一直到事务提交时才检查约束。


 在你把约束的模式修改成 IMMEDIATE 之后,新的约束模式是反作用式地生效的: 任何尚在等待的,需要在事务结束检查地数据修改的约束(在使用 DEFERRED 的时候)都将在执行 SET CONSTRAINTS  命令的时候马上检查。


 从创建的时候开始,一个约束总是表现为下面三个特性之一: INITIALLY DEFERRED, INITIALLY IMMEDIATE DEFERRABLE, 或 INITIALLY IMMEDIATE NOT DEFERRABLE。 第三个特性不会受 SET CONSTRAINTS影响。


 目前,只有外键约束被这个设置影响。检查和***约束总是立即检查的而不是可推迟的。  

NOTES 注意


 这个命令只在当前事务里修改约束的行为。因此,如果你在事务块外面 (BEGIN/COMMIT 对)执行这个命令, 它将显得没有任何作用那样。如果你希望不在每个事务中发出 SET CONSTRAINTS 也能修改约束的行为, 那么在创建这些约束的时候声明 INITIALLY DEFERRED 或者 INITIALLY IMMEDIATE。  

COMPATIBILITY 兼容性


 这条命令与 SQL 标准里定义的行为兼容,只不过,在 PostgreSQL 里,它只适用于外键约束。  

#p#

NAME

SET CONSTRAINTS - set the constraint mode of the current transaction

SYNOPSIS

SET CONSTRAINTS { ALL | name [, ...] } { DEFERRED | IMMEDIATE }

DESCRIPTION

SET CONSTRAINTS sets the behavior of constraint evaluation in the current transaction. In IMMEDIATE mode, constraints are checked at the end of each statement. In DEFERRED mode, constraints are not checked until transaction commit.

When you change the mode of a constraint to be IMMEDIATE, the new constraint mode takes effect retroactively: any outstanding data modifications that would have been checked at the end of the transaction (when using DEFERRED) are instead checked during the execution of the SET CONSTRAINTS command.

Upon creation, a constraint is always give one of three characteristics: INITIALLY DEFERRED, INITIALLY IMMEDIATE DEFERRABLE, or INITIALLY IMMEDIATE NOT DEFERRABLE. The third class is not affected by the SET CONSTRAINTS command.

Currently, only foreign key constraints are affected by this setting. Check and unique constraints are always effectively initially immediate not deferrable.  

NOTES

This command only alters the behavior of constraints within the current transaction. Thus, if you execute this command outside of a transaction block (BEGIN/COMMIT pair), it will not appear to have any effect. If you wish to change the behavior of a constraint without needing to issue a SET CONSTRAINTS command in every transaction, specify INITIALLY DEFERRED or INITIALLY IMMEDIATE when you create the constraint.  

COMPATIBILITY

This command complies with the behavior defined in the SQL standard, except for the limitation that, in PostgreSQL, it only applies to foreign-key constraints.

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 17:50:19

SET中文man

2011-08-24 18:02:22

SET TRANSAC中文man

2011-08-24 17:58:08

SET SESSION中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man
点赞
收藏

51CTO技术栈公众号