PostgreSQL 18 ← 17
SYSTEM CATALOG · System catalog
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.
Checked column by column against a PostgreSQL 18.6 instance · Raw measurement record ↗
Columns PostgreSQL 18
pg_constraint| COLUMN | TYPE | DESCRIPTION |
|---|---|---|
oid |
oidNOT NULL |
Row identifier |
conname |
nameNOT NULL |
Constraint name (not necessarily unique!) |
connamespace |
oidNOT NULL |
The OID of the namespace that contains this constraintReferences:pg_namespace.oid |
contype |
"char"NOT NULLDocumented as:char |
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 |
booleanNOT NULLDocumented as:bool |
Is the constraint deferrable? |
condeferred |
booleanNOT NULLDocumented as:bool |
Is the constraint deferred by default? |
conenforced |
booleanNOT NULLDocumented as:bool |
Is the constraint enforced? |
convalidated |
booleanNOT NULLDocumented as:bool |
Has the constraint been validated? |
conrelid |
oidNOT NULL |
The table this constraint is on; zero if not a table constraintReferences:pg_class.oid |
contypid |
oidNOT NULL |
The domain this constraint is on; zero if not a domain constraintReferences:pg_type.oid |
conindid |
oidNOT NULL |
The index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zeroReferences:pg_class.oid |
conparentid |
oidNOT NULL |
The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zeroReferences:pg_constraint.oid |
confrelid |
oidNOT NULL |
If a foreign key, the referenced table; else zeroReferences:pg_class.oid |
confupdtype |
"char"NOT NULLDocumented as:char |
Foreign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default |
confdeltype |
"char"NOT NULLDocumented as:char |
Foreign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default |
confmatchtype |
"char"NOT NULLDocumented as:char |
Foreign key match type: f = full, p = partial, s = simple |
conislocal |
booleanNOT NULLDocumented as:bool |
This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously. |
coninhcount |
smallintNOT NULLDocumented as:int2 |
The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed. |
connoinherit |
booleanNOT NULLDocumented as:bool |
This constraint is defined locally for the relation. It is a non-inheritable constraint. |
conperiod |
booleanNOT NULLDocumented as:bool |
This constraint is defined with WITHOUT OVERLAPS (for primary keys and unique constraints) or PERIOD (for foreign keys). |
conkey |
smallint[]Documented as:int2[] |
If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columnsReferences:pg_attribute.attnum |
confkey |
smallint[]Documented as:int2[] |
If a foreign key, list of the referenced columnsReferences:pg_attribute.attnum |
conpfeqop |
oid[] |
If a foreign key, list of the equality operators for PK = FK comparisonsReferences:pg_operator.oid |
conppeqop |
oid[] |
If a foreign key, list of the equality operators for PK = PK comparisonsReferences:pg_operator.oid |
conffeqop |
oid[] |
If a foreign key, list of the equality operators for FK = FK comparisonsReferences:pg_operator.oid |
confdelsetcols |
smallint[]Documented as:int2[] |
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.References:pg_attribute.attnum |
conexclop |
oid[] |
If an exclusion constraint or WITHOUT OVERLAPS primary key/unique constraint, list of the per-column exclusion operators.References:pg_operator.oid |
conbin |
pg_node_tree |
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.) |
Columns marked "implicit" are not included in SELECT *; some early statistics views are completed from same-version source, and the extra provenance is shown in the column description.
Common system columns 6
System attributes PostgreSQL provides, normally not expanded by SELECT *. Kept separately so they are not mixed in with ordinary columns.
| Columns | Type | attnum |
|---|---|---|
tableoid | oid | -6 |
cmax | cid | -5 |
xmax | xid | -4 |
cmin | cid | -3 |
xmin | xid | -2 |
ctid | tid | -1 |
Column evolution matrix
Hover a cell for the column type9.0 is the coverage baseline; a column already present in the baseline is not marked as added. The matrix aligns columns by name, so a rename appears as the old column removed and a new column added.
Evolution timeline
Changes between adjacent majorsPostgreSQL 17 ← 16
PostgreSQL 16 ← 15
PostgreSQL 15 ← 14
PostgreSQL 14 ← 13
PostgreSQL 12 ← 11
PostgreSQL 11 ← 10
PostgreSQL 9.3 ← 9.2
PostgreSQL 9.2 ← 9.1
PostgreSQL 9.1 ← 9.0
Compare any two versions
Pick two versions to see added, removed, and retyped columns. The interactive comparison needs JavaScript; the evolution timeline reads fine without it.