CREATE CONSTRAINT TRIGGER
define a new constraint trigger
英文手册覆盖始于 PostgreSQL 6.4. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 9.0·选择有来源记录的版本
此版本暂无所选语言的定义,以下显示原始英文内容。
- anchor
- SQL-CREATECONSTRAINT
- file
- sql-createconstraint.html
- lang
- en
- name
- CREATE CONSTRAINT TRIGGER
- purpose
- define a new constraint trigger
- purpose zh
- 未知
- sections same as
- 未知
- slug
- 9.0
语法
CREATE CONSTRAINT TRIGGER name
AFTER event [ OR ... ]
ON table_name
[ FROM referenced_table_name ]
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
FOR EACH ROW
[ WHEN ( condition ) ]
EXECUTE PROCEDURE function_name ( arguments )语法图
从左向右阅读;分支表示选择,旁路表示可选,循环表示重复。点击带下划线的参数可打开对应规则。
版本定义 PG 9.0
CREATE CONSTRAINT TRIGGER name
AFTER event [ OR ... ]
ON table_name
[ FROM referenced_table_name ]
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
FOR EACH ROW
[ WHEN ( condition ) ]
EXECUTE PROCEDURE function_name ( arguments )Description
CREATE CONSTRAINT TRIGGER creates a constraint trigger. This is the same as a regular trigger except that the timing of the trigger firing can be adjusted using SET CONSTRAINTS. Constraint triggers must be AFTER ROW triggers. They can be fired either at the end of the statement causing the triggering event, or at the end of the containing transaction; in the latter case they are said to be deferred. A pending deferred-trigger firing can also be forced to happen immediately by using SET CONSTRAINTS.
Parameters
nameThe name of the constraint trigger. This is also the name to use when modifying the trigger's behavior using
SET CONSTRAINTS. The name cannot be schema-qualified — the trigger inherits the schema of its table.eventOne of
INSERT,UPDATE, orDELETE; this specifies the event that will fire the trigger. Multiple events can be specified usingOR.table_nameThe (possibly schema-qualified) name of the table in which the triggering events occur.
referenced_table_nameThe (possibly schema-qualified) name of another table referenced by the constraint. This option is used for foreign-key constraints and is not recommended for general use.
DEFERRABLENOT DEFERRABLEINITIALLY IMMEDIATEINITIALLY DEFERREDThe default timing of the trigger. See the CREATE TABLE documentation for details of these constraint options.
conditionA Boolean expression that determines whether the trigger function will actually be executed. This acts the same as in CREATE TRIGGER. Note in particular that evaluation of the
WHENcondition is not deferred, but occurs immediately after the row update operation is performed. If the condition does not evaluate totruethen the trigger is not queued for deferred execution.function_nameThe function to call when the trigger is fired. See CREATE TRIGGER for details.
argumentsOptional argument strings to pass to the trigger function. See CREATE TRIGGER for details.
Compatibility
CREATE CONSTRAINT TRIGGER is a PostgreSQL extension of the SQL standard.
See Also
CREATE TRIGGER, DROP TRIGGER, SET CONSTRAINTS比较版本
完整来源事实
synopsis html
CREATE CONSTRAINT TRIGGER <code class="replaceable"><i>name</i></code>
AFTER <code class="replaceable"><i>event</i></code> [ OR ... ]
ON <code class="replaceable"><i>table_name</i></code>
[ FROM <code class="replaceable"><i>referenced_table_name</i></code> ]
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
FOR EACH ROW
[ WHEN ( <code class="replaceable"><i>condition</i></code> ) ]
EXECUTE PROCEDURE <code class="replaceable"><i>function_name</i></code> ( <code class="replaceable"><i>arguments</i></code> )synopsis text
CREATE CONSTRAINT TRIGGER name
AFTER event [ OR ... ]
ON table_name
[ FROM referenced_table_name ]
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
FOR EACH ROW
[ WHEN ( condition ) ]
EXECUTE PROCEDURE function_name ( arguments )来源引用
定义来源
center · PostgreSQL 9.0 · a709ab85
正文语言: en · a709ab85