pg_constraint

The pg_constraint catalog provides information about table constraints.

Column name Data type Description
oid oid A row identifier.
conname name The constraint name, which is not necessarily unique.
connamespace oid (references pg_namespace.oid) The OID of a namespace that contains the constraint.
contype char The constraint type.
The possible values are:
  • c – CHECK constraint.
  • f – Foreign key.
  • n – Not NULL constraint.
  • p – Primary key.
  • u – Unique.
  • t – Constraint trigger.
  • x – Exclusion constraint.
condeferrable bool Specifies whether the constraint is deferrable (TRUE) or not (FALSE).
condeferred bool Specifies whether the constraint is deferred by default (TRUE) or not (FALSE).
conenforced bool Specifies whether the constraint is enforced (TRUE) or not (FALSE).
convalidated bool Specifies whether the constraint has been validated (TRUE) or not (FALSE).
conrelid oid The OID of the table where the constraint is enabled.
0 – Not a table constraint.
contypid oid The OID of the domain where the constraint is enabled.
0 – Not a domain constraint.
conindid oid The OID of the supporting index for unique, primary key, foreign key, or exclusion constraints.
0 – No supporting index.
conparentid oid The OID of the corresponding constraint on the parent partitioned table if this is a partition constraint.
0 – No corresponding constraint.
confrelid oid The OID of the referenced table if this is a foreign key.
0 – No referenced table.
confupdtype char Foreign key update action.
The possible values are:
  • a – No action.
  • r – Restrict.
  • c – Cascade.
  • n – SET NULL.
  • d – SET DEFAULT.
confdeltype char Foreign key delete action.
The possible values are:
  • a – No action.
  • r – Restrict.
  • c – Cascade.
  • n – SET NULL.
  • d – SET DEFAULT.
confmatchtype char Foreign key match type.
The possible values are:
  • f – Full.
  • p – Partial.
  • s – Simple.
conislocal bool Specifies that the constraint is defined locally for the relation.
Note: A constraint can be locally defined and inherited simultaneously.
coninhcount int2 The number of direct inheritance ancestors.
Non-zero values prevent the constraint from being dropped or renamed.
connoinherit bool Specifies that the constraint is locally defined and non-inheritable.
conperiod bool Specifies whether the constraint uses WITHOUT OVERLAPS (for primary keys/unique constraints) or PERIOD (for foreign keys).
conkey int2[] (references pg_attribute.attnum) The list of constrained columns for table constraints (including foreign keys but excluding triggers).
confkey int2[] (references pg_attribute.attnum) The list of referenced columns for foreign keys.
conpfeqop oid[] (references pg_operator.oid) Equality operators used for PK = FK comparisons in foreign keys.
conppeqop oid[] (references pg_operator.oid) Equality operators used for PK = PK comparisons in foreign keys.
conffeqop oid[] (references pg_operator.oid) Equality operators used for FK = FK comparisons in foreign keys.
confdelsetcols int2[] (references pg_attribute.attnum) Columns updated for foreign keys with SET NULL or SET DEFAULT.
NULL – All referencing columns.
conexclop oid[] (references pg_operator.oid) Per-column exclusion operators for exclusion or WITHOUT OVERLAPS constraints.
conbin pg_node_tree Internal representation of check constraint expressions.
Note: Use pg_get_constraintdef() to obtain the full definition.