class="parameter">constraint | REFERENCES
- referenced table
- (referenced column)
- [ MATCH match type ]
+ reftable
+ (refcolumn)
+ [ MATCH matchtype ]
[ ON DELETE action ]
[ ON UPDATE action ]
[ [ NOT ] DEFERRABLE ]
- [ INITIALLY check time ] }
+ [ INITIALLY checktime ] }
[, ...]
[ CONSTRAINT name ] REFERENCES
-referenced table [ ( referenced column ) ]
+reftable [ ( refcolumn ) ]
[ MATCH matchtype ]
[ ON DELETE action ]
[ ON UPDATE action ]
[ [ NOT ] DEFERRABLE ]
-[ INITIALLY check time ]
+[ INITIALLY checktime ]
The REFERENCES constraint specifies a rule that a column
Inputs
+
+
- referenced table
+ reftable
The table that contains the data to check against.
+
- referenced column
+ refcolumn
- The column in the referenced table
+ The column in reftable
to check the data against. If this is not specified, the PRIMARY KEY of the
- referenced table is used.
+ reftable is used.
+
[ NOT ] DEFERRABLE
+
- INITIALLY check time
+ INITIALLY checktime
- check time has two possible values
+ checktime has two possible values
which specify the default time to check the constraint.
+
DEFERRED
- Check this constraint at the end of the transaction.
-
+
+ Check this constraint at the end of the transaction.
+
+
+
IMMEDIATE
- Check this constraint after each statement.
-
-
+
+ Check this constraint after each statement.
+
+
+
ERROR: name referential integrity violation - key referenced from
-table not found in referenced table
+table not found in reftable
Currently
Postgres only supports
- MATCH FULL and an unspecified MATCH type.
+ MATCH FULL and an unspecified match type.
In addition, the referenced columns are supposed to be
the columns of a UNIQUE constraint in the referenced table,
however
Postgres does not
enforce this.
+
[ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( column [, ...] )
[ CONSTRAINT name ] CHECK ( constraint )
[ CONSTRAINT name ] FOREIGN KEY ( column [, ...] )
- REFERENCES referenced table
- (referenced column [, ...] )
- [ MATCH <match type> ]
+ REFERENCES reftable
+ (refcolumn [, ...] )
+ [ MATCH <replaceable class="parameter">matchtypee> ]
[ ON DELETE action ]
[ ON UPDATE action ]
[ [ NOT ] DEFERRABLE ]
- [ INITIALLY check time ]
+ [ INITIALLY checktime ]
- 1">
+ 2">
2000-02-04
[ CONSTRAINT name ]
FOREIGN KEY ( column [, ...] ) REFERENCES
-referenced table [ ( referenced column [, ...] ) ]
+reftable [ ( refcolumn [, ...] ) ]
[ MATCH matchtype ]
[ ON DELETE action ]
[ ON UPDATE action ]
[ [ NOT ] DEFERRABLE ]
-[ INITIALLY check time ]
+[ INITIALLY checktime ]
The REFERENCES constraint specifies a rule that a column
a FOREIGN KEY table constraint.
- 1">
+ 5">
Inputs
- referenced table
+ reftable
The table that contains the data to check against.
referenced column [, ...]
- One or more column in the referenced table
+ One or more column in the reftable
to check the data against. If this is not specified, the PRIMARY KEY of the
- referenced table is used.
+ reftable is used.
- INITIALLY check time
+ INITIALLY checktime
- check time has two possible values
+ checktime has two possible values
which specify the default time to check the constraint.
DEFERRED
- Check this constraint at the end of the transaction.
-
+
+ Check this constraint at the end of the transaction.
+
+
IMMEDIATE
- Check this constraint after each statement.
-
+
+ Check this constraint after each statement.
+
+
- 2">
+ 6">
2000-02-04
ERROR: name referential integrity violation - key referenced from
-table not found in referenced table
+table not found in reftable