Restrictions on Referential Constraints

You must have the REFERENCES privilege to create a referential constraint.

The following restrictions apply to the column that is specified (the referenced column) in the REFERENCES clause:
  • The referenced and referencing tables must be in the same database.
  • The referenced column (or set of columns) must have a unique or primary-key constraint.
  • The referencing and referenced columns must be the same data type.
    The only exceptions are that a referencing column must be an integer data type if the referenced column is a serial data type:
    • For BIGSERIAL referenced columns, use BIGINT referencing columns.
    • For SERIAL referenced columns, use INT referencing columns.
    • For SERIAL8 referenced columns, use INT8 referencing columns.
  • You cannot place a referential constraint on a BYTE or TEXT column.
  • You cannot place a constraint on any column of a RAW table.
  • Constraints uses the collation in effect at their time of creation.
  • A column-level REFERENCES clause can include only a single column name.
  • Maximum number of columns in a table-level REFERENCES clause is 16.
  • The total length of the columns in a table-level REFERENCES clause cannot exceed 390 bytes.