select open change scope Open full search

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

SYSTEM CATALOGS / SYSTEM CATALOGS

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

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

Columns 28

ColumnTypeDescription / reference
oidoidRow identifier
connamenameConstraint name (not necessarily unique!)
connamespaceoidThe OID of the namespace that contains this constraint
pg_namespace.oid
contypecharc = check constraint, f = foreign key constraint, n = not-null constraint, p = primary key constraint, u = unique constraint, t = constraint trigger, x = exclusion constraint
condeferrableboolIs the constraint deferrable?
condeferredboolIs the constraint deferred by default?
conenforcedboolIs the constraint enforced?
convalidatedboolHas the constraint been validated?
conrelidoidThe table this constraint is on; zero if not a table constraint
pg_class.oid
contypidoidThe domain this constraint is on; zero if not a domain constraint
pg_type.oid
conindidoidThe index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero
pg_class.oid
conparentidoidThe corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero
confrelidoidIf a foreign key, the referenced table; else zero
pg_class.oid
confupdtypecharForeign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default
confdeltypecharForeign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default
confmatchtypecharForeign key match type: f = full, p = partial, s = simple
conislocalboolThis constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously.
coninhcountint2The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed.
connoinheritboolThis constraint is defined locally for the relation. It is a non-inheritable constraint.
conperiodboolThis 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
Column9.09.19.29.39.49.59.61011121314151617181920
oid···
conname
connamespace
contype
condeferrable
condeferred
convalidated·
conrelid
contypid
conindid
confrelid
confupdtype
confdeltype
confmatchtype
conislocal
coninhcount
connoinherit··
conkey
confkey
conpfeqop
conppeqop
conffeqop
conexclop
conbin
consrc·········
conparentid········
confdelsetcols············
conenforced···············
conperiod···············
Version history 10
  1. PG 17 → 18changed
  2. PG 16 → 17changed
  3. PG 15 → 16changed
  4. PG 14 → 15changed
  5. PG 13 → 14changed
  6. PG 11 → 12changed
  7. PG 10 → 11changed
  8. PG 9.2 → 9.3changed
  9. PG 9.1 → 9.2changed
  10. PG 9.0 → 9.1changed

Definition snapshot: english-manuals:a2e0e946481539aff9188c26fe5… · English manual source