pg_constraint
pg_constraint#
The pg_constraint system catalog table stores check and foreign key 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 table. Check constraints on domains are stored here, too.
Table 1. pg_catalog.pg_constraint
column |
type |
references |
description |
|---|---|---|---|
|
name |
Constraint name |
|
|
oid |
pg_namespace.oid |
The OID of the namespace (schema) that contains this constraint. |
|
char |
|
|
|
boolean |
Is the constraint deferrable? |
|
|
boolean |
Is the constraint deferred by default? |
|
|
oid |
pg_class_internal.oid |
The table this constraint is on; 0 if not a table constraint. |
|
oid |
Root OID of the table this constraint is on; |
|
|
oid |
pg_type.oid |
The domain this constraint is on; 0 if not a domain constraint. |
|
oid |
pg_class_internal.oid |
If a foreign key, the referenced table; else 0. |
|
char |
Foreign key update action code. |
|
|
char |
Foreign key deletion action code. |
|
|
char |
Foreign key match type. |
|
|
smallint[] |
pg_attribute.attnum |
If a table constraint, list of columns which the constraint constrains. |
|
smallint[] |
pg_attribute.attnum |
If a foreign key, list of the referenced columns. |
|
text |
If a check constraint, an internal representation of the expression. |
|
|
text |
If a check constraint, a human-readable representation of the expression. This is not updated when referenced objects change; for example, it won’t track renaming of columns. Rather than relying on this field, it is best to use |