4 The catalog pg_constraint stores check, not-null, primary key, unique,
5 foreign key, and exclusion constraints on tables. (Column constraints
6 are not treated specially. Every column constraint is equivalent to
7 some table constraint.)
9 User-defined constraint triggers (created with CREATE CONSTRAINT
10 TRIGGER) also give rise to an entry in this table.
12 Check constraints on domains are stored here, too.
14 Table 52.13. pg_constraint Columns
26 Constraint name (not necessarily unique!)
28 connamespace oid (references pg_namespace.oid)
30 The OID of the namespace that contains this constraint
34 c = check constraint, f = foreign key constraint, n = not-null
35 constraint, p = primary key constraint, u = unique constraint, t =
36 constraint trigger, x = exclusion constraint
40 Is the constraint deferrable?
44 Is the constraint deferred by default?
48 Is the constraint enforced?
52 Has the constraint been validated?
54 conrelid oid (references pg_class.oid)
56 The table this constraint is on; zero if not a table constraint
58 contypid oid (references pg_type.oid)
60 The domain this constraint is on; zero if not a domain constraint
62 conindid oid (references pg_class.oid)
64 The index supporting this constraint, if it's a unique, primary key,
65 foreign key, or exclusion constraint; else zero
67 conparentid oid (references pg_constraint.oid)
69 The corresponding constraint of the parent partitioned table, if this
70 is a constraint on a partition; else zero
72 confrelid oid (references pg_class.oid)
74 If a foreign key, the referenced table; else zero
78 Foreign key update action code: a = no action, r = restrict, c =
79 cascade, n = set null, d = set default
83 Foreign key deletion action code: a = no action, r = restrict, c =
84 cascade, n = set null, d = set default
88 Foreign key match type: f = full, p = partial, s = simple
92 This constraint is defined locally for the relation. Note that a
93 constraint can be locally defined and inherited simultaneously.
97 The number of direct inheritance ancestors this constraint has. A
98 constraint with a nonzero number of ancestors cannot be dropped nor
103 This constraint is defined locally for the relation. It is a
104 non-inheritable constraint.
108 This constraint is defined with WITHOUT OVERLAPS (for primary keys and
109 unique constraints) or PERIOD (for foreign keys).
111 conkey int2[] (references pg_attribute.attnum)
113 If a table constraint (including foreign keys, but not constraint
114 triggers), list of the constrained columns
116 confkey int2[] (references pg_attribute.attnum)
118 If a foreign key, list of the referenced columns
120 conpfeqop oid[] (references pg_operator.oid)
122 If a foreign key, list of the equality operators for PK = FK
125 conppeqop oid[] (references pg_operator.oid)
127 If a foreign key, list of the equality operators for PK = PK
130 conffeqop oid[] (references pg_operator.oid)
132 If a foreign key, list of the equality operators for FK = FK
135 confdelsetcols int2[] (references pg_attribute.attnum)
137 If a foreign key with a SET NULL or SET DEFAULT delete action, the
138 columns that will be updated. If null, all of the referencing columns
141 conexclop oid[] (references pg_operator.oid)
143 If an exclusion constraint or WITHOUT OVERLAPS primary key/unique
144 constraint, list of the per-column exclusion operators.
148 If a check constraint, an internal representation of the expression.
149 (It's recommended to use pg_get_constraintdef() to extract the
150 definition of a check constraint.)
152 In the case of an exclusion constraint, conkey is only useful for
153 constraint elements that are simple column references. For other cases,
154 a zero appears in conkey and the associated index must be consulted to
155 discover the expression that is constrained. (conkey thus has the same
156 contents as pg_index.indkey for the index.)
160 pg_class.relchecks needs to agree with the number of check-constraint
161 entries found in this table for each relation.