↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

System Catalogs / System catalogs

pg_constraint

Read the PG 18 manual

The catalog pg_constraint stores check, not-null, primary key, unique, foreign key, and exclusion constraints on tables.

Reading PG 18current·documented in 24 of 24 versions, 7.4 to 20

Kind
System catalogs
Columns in this snapshot
28
Definition source
English manual
Metadata snapshot
18.6

Columns 28

As listed in the PostgreSQL 18 manual.

ColumnTypeDescription / reference
oidoidNOT NULLRow identifier
connamenameNOT NULLConstraint name (not necessarily unique!)
connamespaceoidNOT NULLThe OID of the namespace that contains this constraint
pg_namespace.oid
contypecharNOT NULLc = check constraint, f = foreign key constraint, n = not-null constraint, p = primary key constraint, u = unique constraint, t = constraint trigger, x = exclusion constraint
condeferrableboolNOT NULLIs the constraint deferrable?
condeferredboolNOT NULLIs the constraint deferred by default?
conenforcedboolNOT NULLIs the constraint enforced?
convalidatedboolNOT NULLHas the constraint been validated?
conrelidoidNOT NULLThe table this constraint is on; zero if not a table constraint
pg_class.oid
contypidoidNOT NULLThe domain this constraint is on; zero if not a domain constraint
pg_type.oid
conindidoidNOT NULLThe index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero
pg_class.oid
conparentidoidNOT NULLThe corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero
pg_constraint.oid
confrelidoidNOT NULLIf a foreign key, the referenced table; else zero
pg_class.oid
confupdtypecharNOT NULLForeign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default
confdeltypecharNOT NULLForeign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default
confmatchtypecharNOT NULLForeign key match type: f = full, p = partial, s = simple
conislocalboolNOT NULLThis constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously.
coninhcountint2NOT NULLThe number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed.
connoinheritboolNOT NULLThis constraint is defined locally for the relation. It is a non-inheritable constraint.
conperiodboolNOT NULLThis constraint is defined with WITHOUT OVERLAPS (for primary keys and unique constraints) or PERIOD (for foreign keys).
conkeyint2[]If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns
pg_attribute.attnum
confkeyint2[]If a foreign key, list of the referenced columns
pg_attribute.attnum
conpfeqopoid[]If a foreign key, list of the equality operators for PK = FK comparisons
pg_operator.oid
conppeqopoid[]If a foreign key, list of the equality operators for PK = PK comparisons
pg_operator.oid
conffeqopoid[]If a foreign key, list of the equality operators for FK = FK comparisons
pg_operator.oid
confdelsetcolsint2[]If a foreign key with a SET NULL or SET DEFAULT delete action, the columns that will be updated. If null, all of the referencing columns will be updated.
pg_attribute.attnum
conexclopoid[]If an exclusion constraint or WITHOUT OVERLAPS primary key/unique constraint, list of the per-column exclusion operators.
pg_operator.oid
conbinpg_node_treeIf a check constraint, an internal representation of the expression. (It's recommended to use pg_get_constraintdef() to extract the definition of a check constraint.)
Column history across versions
Version history 13
  1. 17 → 18 changed
  2. 16 → 17 reworded
  3. 15 → 16 changed
  4. 14 → 15 changed
  5. 13 → 14 reworded
  6. 11 → 12 changed
  7. 10 → 11 changed
  8. 9.2 → 9.3 reworded
  9. 9.1 → 9.2 changed
  10. 9.0 → 9.1 changed
  11. 8.4 → 9.0 changed
  12. 8.3 → 8.4 changed
  13. 8.2 → 8.3 changed

Definition snapshot: english-manuals:3228acb54b2d8175450a80630d8… · English manual source