1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.17 2006/10/17 12:53:03 momjian Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.18 2007/02/10 20:43:59 tgl Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -15,13 +15,13 @@ PostgreSQL documentation
15
15
</refnamediv>
16
16
17
17
<indexterm zone="sql-createconstraint">
18
- <primary>CREATE CONSTRAINT</primary>
18
+ <primary>CREATE CONSTRAINT TRIGGER </primary>
19
19
</indexterm>
20
20
21
21
<refsynopsisdiv>
22
22
<synopsis>
23
23
CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
24
- AFTER <replaceable class="parameter">event [ OR ... ]</replaceable>
24
+ AFTER <replaceable class="parameter">event</replaceable> [ OR ... ]
25
25
ON <replaceable class="parameter">table_name</replaceable>
26
26
[ FROM <replaceable class="parameter">referenced_table_name</replaceable> ]
27
27
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
@@ -34,27 +34,30 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
34
34
<title>Description</title>
35
35
36
36
<para>
37
- <command>CREATE CONSTRAINT TRIGGER</command> is used within
38
- <command>CREATE TABLE</command>/<command>ALTER TABLE</command> and by
39
- <application>pg_dump</application> to create the special triggers for
40
- referential integrity.
41
- It is not intended for general use.
42
- </para>
43
- </refsect1>
37
+ <command>CREATE CONSTRAINT TRIGGER</command> creates a
38
+ <firstterm>constraint trigger</>. This is the same as a regular trigger
39
+ except that the timing of the trigger firing can be adjusted using
40
+ <xref linkend="SQL-SET-CONSTRAINTS" endterm="SQL-SET-CONSTRAINTS-TITLE">.
41
+ Constraint triggers must be <literal>AFTER ROW</> triggers. They can
42
+ be fired either at the end of the statement causing the triggering event,
43
+ or at the end of the containing transaction; in the latter case they are
44
+ said to be <firstterm>deferred</>. A pending deferred-trigger firing can
45
+ also be forced to happen immediately by using <command>SET CONSTRAINTS</>.
46
+ </para>
47
+ </refsect1>
44
48
45
- <refsect1>
49
+ <refsect1>
46
50
<title>Parameters</title>
47
51
48
52
<variablelist>
49
53
<varlistentry>
50
54
<term><replaceable class="PARAMETER">name</replaceable></term>
51
55
<listitem>
52
56
<para>
53
- The name of the constraint trigger. The actual name of the
54
- created trigger will be of the form
55
- <literal>RI_ConstraintTrigger_0000</literal> (where 0000 is some number
56
- assigned by the server).
57
- Use this assigned name when dropping the trigger.
57
+ The name of the constraint trigger. This is also the name to use
58
+ when modifying the trigger's behavior using <command>SET CONSTRAINTS</>.
59
+ The name cannot be schema-qualified — the trigger inherits the
60
+ schema of its table.
58
61
</para>
59
62
</listitem>
60
63
</varlistentry>
@@ -84,8 +87,9 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
84
87
<term><replaceable class="PARAMETER">referenced_table_name</replaceable></term>
85
88
<listitem>
86
89
<para>
87
- The (possibly schema-qualified) name of the table referenced by the
88
- constraint. Used by foreign key constraints triggers.
90
+ The (possibly schema-qualified) name of another table referenced by the
91
+ constraint. This option is used for foreign-key constraints and is not
92
+ recommended for general use.
89
93
</para>
90
94
</listitem>
91
95
</varlistentry>
@@ -97,17 +101,29 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
97
101
<term><literal>INITIALLY DEFERRED</literal></term>
98
102
<listitem>
99
103
<para>
104
+ The default timing of the trigger.
100
105
See the <xref linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-TITLE">
101
106
documentation for details of these constraint options.
102
107
</para>
103
108
</listitem>
104
109
</varlistentry>
105
110
106
111
<varlistentry>
107
- <term><replaceable class="PARAMETER">funcname</replaceable>(<replaceable class="PARAMETER">args</replaceable>) </term>
112
+ <term><replaceable class="PARAMETER">funcname</replaceable></term>
108
113
<listitem>
109
114
<para>
110
- The function to call as part of the trigger processing. See <xref
115
+ The function to call when the trigger is fired. See <xref
116
+ linkend="SQL-CREATETRIGGER" endterm="SQL-CREATETRIGGER-TITLE"> for
117
+ details.
118
+ </para>
119
+ </listitem>
120
+ </varlistentry>
121
+
122
+ <varlistentry>
123
+ <term><replaceable class="PARAMETER">arguments</replaceable></term>
124
+ <listitem>
125
+ <para>
126
+ Optional argument strings to pass to the trigger function. See <xref
111
127
linkend="SQL-CREATETRIGGER" endterm="SQL-CREATETRIGGER-TITLE"> for
112
128
details.
113
129
</para>
@@ -119,11 +135,19 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
119
135
<refsect1>
120
136
<title>Compatibility</title>
121
137
<para>
122
- <command>CREATE CONTRAINT TRIGGER</command> is a
138
+ <command>CREATE CONSTRAINT TRIGGER</command> is a
123
139
<productname>PostgreSQL</productname> extension of the <acronym>SQL</>
124
140
standard.
125
141
</para>
126
142
</refsect1>
127
143
128
- </refentry>
144
+ <refsect1>
145
+ <title>See Also</title>
129
146
147
+ <simplelist type="inline">
148
+ <member><xref linkend="sql-createtrigger" endterm="sql-createtrigger-title"></member>
149
+ <member><xref linkend="sql-droptrigger" endterm="sql-droptrigger-title"></member>
150
+ <member><xref linkend="sql-set-constraints" endterm="sql-set-constraints-title"></member>
151
+ </simplelist>
152
+ </refsect1>
153
+ </refentry>
0 commit comments