Restrictions on Referential Constraints

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

When you use the REFERENCES clause, you must observe the following restrictions:
  • The referenced and referencing tables must be in the same database.
  • The referenced column (or set of columns when you use the multiple-column constraint format) must have a unique or primary-key constraint.
  • The data types of the referencing and referenced columns must be identical.
    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 constraint on any column of a RAW table.
  • You cannot place a referential constraint on a BYTE, TEXT, BLOB, or CLOB column.
  • When you use the single-column constraint format, you can reference only one column.
  • When you use the multiple-column constraint format, the maximum number of columns in the REFERENCES clause is 16, and the total length of the columns cannot exceed 390 bytes if the page size is 2 kilobytes. (The maximum length increases with the page size.)