52.13. pg_constraint
pg_constraint
The catalog pg_constraint stores check, not-null, primary key, unique, foreign key, and exclusion constraints on tables. (Column constraints are not treated specially. Every column constraint is equivalent to some table constraint.)
User-defined constraint triggers (created with CREATE CONSTRAINT TRIGGER) also give rise to an entry in this table.
Check constraints on domains are stored here, too.
Column Type Description |
|---|
oid Row identifier |
conname Constraint name (not necessarily unique!) |
connamespace The OID of the namespace that contains this constraint |
contype
|
condeferrable Is the constraint deferrable? |
condeferred Is the constraint deferred by default? |
conenforced Is the constraint enforced? |
convalidated Has the constraint been validated? |
conrelid The table this constraint is on; zero if not a table constraint |
contypid The domain this constraint is on; zero if not a domain constraint |
conindid The index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero |
conparentid The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero |
confrelid If a foreign key, the referenced table; else zero |
confupdtype Foreign key update action code: |
confdeltype Foreign key deletion action code: |
confmatchtype Foreign key match type: |
conislocal This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously. |
coninhcount The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed. |
connoinherit This constraint is defined locally for the relation. It is a non-inheritable constraint. |
conperiod This constraint is defined with |
conkey If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns |
confkey If a foreign key, list of the referenced columns |
conpfeqop If a foreign key, list of the equality operators for PK = FK comparisons |
conppeqop If a foreign key, list of the equality operators for PK = PK comparisons |
conffeqop If a foreign key, list of the equality operators for FK = FK comparisons |
confdelsetcols If a foreign key with a |
conexclop If an exclusion constraint or |
conbin If a check constraint, an internal representation of the expression. (It's recommended to use |
: pg_constraint Columns
In the case of an exclusion constraint, conkey is only useful for constraint elements that are simple column references. For other cases, a zero appears in conkey and the associated index must be consulted to discover the expression that is constrained. (conkey thus has the same contents as pg_index.indkey for the index.)
pg_class.relchecks needs to agree with the number of check-constraint entries found in this table for each relation.