1 <!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_constraints.sgml,v 1.9 2003/09/22 00:16:58 petere Exp $ -->
2 <refentry id="SQL-SET-CONSTRAINTS">
4 <refentrytitle id="SQL-SET-CONSTRAINTS-title">SET CONSTRAINTS</refentrytitle>
5 <refmiscinfo>SQL - Language Statements</refmiscinfo>
9 <refname>SET CONSTRAINTS</refname>
10 <refpurpose>set the constraint mode of the current transaction</refpurpose>
13 <indexterm zone="sql-set-constraints">
14 <primary>SET CONSTRAINTS</primary>
19 SET CONSTRAINTS { ALL | <replaceable class="parameter">name</replaceable> [, ...] } { DEFERRED | IMMEDIATE }
24 <title>Description</title>
27 <command>SET CONSTRAINTS</command> sets the behavior of constraint
28 evaluation in the current transaction. In
29 <literal>IMMEDIATE</literal> mode, constraints are checked at the
30 end of each statement. In <literal>DEFERRED</literal> mode,
31 constraints are not checked until transaction commit.
35 When you change the mode of a constraint to be
36 <literal>IMMEDIATE</literal>, the new constraint mode takes effect
37 retroactively: any outstanding data modifications that would have
38 been checked at the end of the transaction (when using
39 <literal>DEFERRED</literal>) are instead checked during the
40 execution of the <command>SET CONSTRAINTS</command> command.
44 Upon creation, a constraint is always give one of three
45 characteristics: <literal>INITIALLY DEFERRED</literal>,
46 <literal>INITIALLY IMMEDIATE DEFERRABLE</literal>, or
47 <literal>INITIALLY IMMEDIATE NOT DEFERRABLE</literal>. The third
48 class is not affected by the <command>SET CONSTRAINTS</command>
53 Currently, only foreign key constraints are affected by this
54 setting. Check and unique constraints are always effectively
55 initially immediate not deferrable.
63 This command only alters the behavior of constraints within the
64 current transaction. Thus, if you execute this command outside of a
66 (<command>BEGIN</command>/<command>COMMIT</command> pair), it will
67 not appear to have any effect. If you wish to change the behavior
68 of a constraint without needing to issue a <command>SET
69 CONSTRAINTS</command> command in every transaction, specify
70 <literal>INITIALLY DEFERRED</literal> or <literal>INITIALLY
71 IMMEDIATE</literal> when you create the constraint.
76 <title>Compatibility</title>
79 This command complies with the behavior defined in the SQL
80 standard, except for the limitation that, in
81 <productname>PostgreSQL</productname>, it only applies to
82 foreign-key constraints.
87 <!-- Keep this comment at the end of the file
92 sgml-minimize-attributes:nil
93 sgml-always-quote-attributes:t
96 sgml-parent-document:nil
97 sgml-default-dtd-file:"../reference.ced"
99 sgml-local-catalogs:("/usr/lib/sgml/catalog")
100 sgml-local-ecat-files:nil