PostgreSQL
52.13. pg_constraint
The catalog pg_constraint
stores check, 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.) Not-null constraints are represented in the pg_attribute
catalog, not here.
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.
Table 52.13. pg_constraint
Columns
Column Type Description |
---|
Row identifier |
Constraint name (not necessarily unique!) |
The OID of the namespace that contains this constraint |
|
Is the constraint deferrable? |
Is the constraint deferred by default? |
Has the constraint been validated? Currently, can be false only for foreign keys and CHECK constraints |
The table this constraint is on; zero if not a table constraint |
The domain this constraint is on; zero if not a domain constraint |
The index supporting this constraint, if it’s a unique, primary key, foreign key, or exclusion constraint; else zero |
The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero |
If a foreign key, the referenced table; else zero |
Foreign key update action code: |
Foreign key deletion action code: |
Foreign key match type: |
This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously. |
The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed. |
This constraint is defined locally for the relation. It is a non-inheritable constraint. |
If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns |
If a foreign key, list of the referenced columns |
If a foreign key, list of the equality operators for PK = FK comparisons |
If a foreign key, list of the equality operators for PK = PK comparisons |
If a foreign key, list of the equality operators for FK = FK comparisons |
If an exclusion constraint, list of the per-column exclusion operators |
If a check constraint, an internal representation of the expression. (It’s recommended to use |
+
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.)
Submit correction
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.
Copyright © 1996-2023 The PostgreSQL Global Development Group