@@ -42,9 +42,8 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
42
42
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET ( <replaceable class="PARAMETER">attribute_option</replaceable> = <replaceable class="PARAMETER">value</replaceable> [, ... ] )
43
43
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> RESET ( <replaceable class="PARAMETER">attribute_option</replaceable> [, ... ] )
44
44
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
45
- ADD <replaceable class="PARAMETER">table_constraint</replaceable>
46
- ADD <replaceable class="PARAMETER">table_constraint_using_index</replaceable>
47
45
ADD <replaceable class="PARAMETER">table_constraint</replaceable> [ NOT VALID ]
46
+ ADD <replaceable class="PARAMETER">table_constraint_using_index</replaceable>
48
47
VALIDATE CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable>
49
48
DROP CONSTRAINT [ IF EXISTS ] <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ]
50
49
DISABLE TRIGGER [ <replaceable class="PARAMETER">trigger_name</replaceable> | ALL | USER ]
@@ -235,27 +234,21 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
235
234
</varlistentry>
236
235
237
236
<varlistentry>
238
- <term><literal>ADD <replaceable class="PARAMETER">table_constraint</replaceable>
239
- [ NOT VALID ]</literal></term>
237
+ <term><literal>ADD <replaceable class="PARAMETER">table_constraint</replaceable> [ NOT VALID ]</literal></term>
240
238
<listitem>
241
239
<para>
242
240
This form adds a new constraint to a table using the same syntax as
243
- <xref linkend="SQL-CREATETABLE">. Newly added foreign key constraints can
244
- also be defined as <literal>NOT VALID</literal> to avoid the
245
- potentially lengthy initial check that must otherwise be performed.
246
- Constraint checks are skipped at create table time, so
247
- <xref linkend="SQL-CREATETABLE"> does not contain this option.
248
- </para>
249
- </listitem>
250
- </varlistentry>
251
-
252
- <varlistentry>
253
- <term><literal>VALIDATE CONSTRAINT</literal></term>
254
- <listitem>
255
- <para>
256
- This form validates a foreign key constraint that was previously created
257
- as <literal>NOT VALID</literal>. Constraints already marked valid do not
258
- cause an error response.
241
+ <xref linkend="SQL-CREATETABLE">, plus the option <literal>NOT
242
+ VALID</literal>, which is currently only allowed for foreign key
243
+ constraints.
244
+ If the constraint is marked <literal>NOT VALID</literal>, the
245
+ potentially-lengthy initial check to verify that all rows in the table
246
+ satisfy the constraint is skipped. The constraint will still be
247
+ enforced against subsequent inserts or updates (that is, they'll fail
248
+ unless there is a matching row in the referenced table). But the
249
+ database will not assume that the constraint holds for all rows in
250
+ the table, until it is validated by using the <literal>VALIDATE
251
+ CONSTRAINT</literal> option.
259
252
</para>
260
253
</listitem>
261
254
</varlistentry>
@@ -311,6 +304,21 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
311
304
</listitem>
312
305
</varlistentry>
313
306
307
+ <varlistentry>
308
+ <term><literal>VALIDATE CONSTRAINT</literal></term>
309
+ <listitem>
310
+ <para>
311
+ This form validates a foreign key constraint that was previously created
312
+ as <literal>NOT VALID</literal>, by scanning the table to ensure there
313
+ are no unmatched rows. Nothing happens if the constraint is
314
+ already marked valid.
315
+ The value of separating validation from initial creation of the
316
+ constraint is that validation requires a lesser lock on the table
317
+ than constraint creation does.
318
+ </para>
319
+ </listitem>
320
+ </varlistentry>
321
+
314
322
<varlistentry>
315
323
<term><literal>DROP CONSTRAINT [ IF EXISTS ]</literal></term>
316
324
<listitem>
0 commit comments