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.
English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- kind
- catalog
- lang
- en
- measured attributes
- true
- metadata release
- 18.6
- runtime verified
- false
- source
- english-manual
Definition PG 18
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.
Catalog columns
| Column | Type | Nullability | Description |
|---|---|---|---|
| oid | oid | Not null | Row identifier |
| conname | name | Not null | Constraint name (not necessarily unique!) |
| connamespace | oid | Not null | The OID of the namespace that contains this constraint |
| contype | char | Not null | c = check constraint, f = foreign key constraint, n = not-null constraint, p = primary key constraint, u = unique constraint, t = constraint trigger, x = exclusion constraint |
| condeferrable | bool | Not null | Is the constraint deferrable? |
| condeferred | bool | Not null | Is the constraint deferred by default? |
| conenforced | bool | Not null | Is the constraint enforced? |
| convalidated | bool | Not null | Has the constraint been validated? |
| conrelid | oid | Not null | The table this constraint is on; zero if not a table constraint |
| contypid | oid | Not null | The domain this constraint is on; zero if not a domain constraint |
| conindid | oid | Not null | The index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero |
| conparentid | oid | Not null | The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero |
| confrelid | oid | Not null | If a foreign key, the referenced table; else zero |
| confupdtype | char | Not null | Foreign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default |
| confdeltype | char | Not null | Foreign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default |
| confmatchtype | char | Not null | Foreign key match type: f = full, p = partial, s = simple |
| conislocal | bool | Not null | This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously. |
| coninhcount | int2 | Not null | The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed. |
| connoinherit | bool | Not null | This constraint is defined locally for the relation. It is a non-inheritable constraint. |
| conperiod | bool | Not null | This constraint is defined with WITHOUT OVERLAPS (for primary keys and unique constraints) or PERIOD (for foreign keys). |
| conkey | int2[] | Nullable | If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns |
| confkey | int2[] | Nullable | If a foreign key, list of the referenced columns |
| conpfeqop | oid[] | Nullable | If a foreign key, list of the equality operators for PK = FK comparisons |
| conppeqop | oid[] | Nullable | If a foreign key, list of the equality operators for PK = PK comparisons |
| conffeqop | oid[] | Nullable | If a foreign key, list of the equality operators for FK = FK comparisons |
| confdelsetcols | int2[] | Nullable | 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. |
| conexclop | oid[] | Nullable | If an exclusion constraint or WITHOUT OVERLAPS primary key/unique constraint, list of the per-column exclusion operators. |
| conbin | pg_node_tree | Nullable | If 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.) |
Compare versions
Complete source facts
runtime columns
oid, conname, connamespace, contype, condeferrable, condeferred, conenforced, convalidated, conrelid, contypid, conindid, conparentid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conperiod, conkey, confkey, conpfeqop, conppeqop, conffeqop, confdelsetcols, conexclop, conbin
Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · catalog-bilingual-repair:3428b991c0a50aa15565f2c2fb7767a7235f864ea22d970eb5a75bca5e8da673
Text language: en · catalog-bilingual-repair:3428b991c0a50aa15565f2c2fb7767a7235f864ea22d970eb5a75bca5e8da673