]> begriffs open source - ai-pg/blob - full-docs/txt/catalog-pg-constraint.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / catalog-pg-constraint.txt
1
2 52.13. pg_constraint #
3
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.)
8
9    User-defined constraint triggers (created with CREATE CONSTRAINT
10    TRIGGER) also give rise to an entry in this table.
11
12    Check constraints on domains are stored here, too.
13
14    Table 52.13. pg_constraint Columns
15
16    Column Type
17
18    Description
19
20    oid oid
21
22    Row identifier
23
24    conname name
25
26    Constraint name (not necessarily unique!)
27
28    connamespace oid (references pg_namespace.oid)
29
30    The OID of the namespace that contains this constraint
31
32    contype char
33
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
37
38    condeferrable bool
39
40    Is the constraint deferrable?
41
42    condeferred bool
43
44    Is the constraint deferred by default?
45
46    conenforced bool
47
48    Is the constraint enforced?
49
50    convalidated bool
51
52    Has the constraint been validated?
53
54    conrelid oid (references pg_class.oid)
55
56    The table this constraint is on; zero if not a table constraint
57
58    contypid oid (references pg_type.oid)
59
60    The domain this constraint is on; zero if not a domain constraint
61
62    conindid oid (references pg_class.oid)
63
64    The index supporting this constraint, if it's a unique, primary key,
65    foreign key, or exclusion constraint; else zero
66
67    conparentid oid (references pg_constraint.oid)
68
69    The corresponding constraint of the parent partitioned table, if this
70    is a constraint on a partition; else zero
71
72    confrelid oid (references pg_class.oid)
73
74    If a foreign key, the referenced table; else zero
75
76    confupdtype char
77
78    Foreign key update action code: a = no action, r = restrict, c =
79    cascade, n = set null, d = set default
80
81    confdeltype char
82
83    Foreign key deletion action code: a = no action, r = restrict, c =
84    cascade, n = set null, d = set default
85
86    confmatchtype char
87
88    Foreign key match type: f = full, p = partial, s = simple
89
90    conislocal bool
91
92    This constraint is defined locally for the relation. Note that a
93    constraint can be locally defined and inherited simultaneously.
94
95    coninhcount int2
96
97    The number of direct inheritance ancestors this constraint has. A
98    constraint with a nonzero number of ancestors cannot be dropped nor
99    renamed.
100
101    connoinherit bool
102
103    This constraint is defined locally for the relation. It is a
104    non-inheritable constraint.
105
106    conperiod bool
107
108    This constraint is defined with WITHOUT OVERLAPS (for primary keys and
109    unique constraints) or PERIOD (for foreign keys).
110
111    conkey int2[] (references pg_attribute.attnum)
112
113    If a table constraint (including foreign keys, but not constraint
114    triggers), list of the constrained columns
115
116    confkey int2[] (references pg_attribute.attnum)
117
118    If a foreign key, list of the referenced columns
119
120    conpfeqop oid[] (references pg_operator.oid)
121
122    If a foreign key, list of the equality operators for PK = FK
123    comparisons
124
125    conppeqop oid[] (references pg_operator.oid)
126
127    If a foreign key, list of the equality operators for PK = PK
128    comparisons
129
130    conffeqop oid[] (references pg_operator.oid)
131
132    If a foreign key, list of the equality operators for FK = FK
133    comparisons
134
135    confdelsetcols int2[] (references pg_attribute.attnum)
136
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
139    will be updated.
140
141    conexclop oid[] (references pg_operator.oid)
142
143    If an exclusion constraint or WITHOUT OVERLAPS primary key/unique
144    constraint, list of the per-column exclusion operators.
145
146    conbin pg_node_tree
147
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.)
151
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.)
157
158 Note
159
160    pg_class.relchecks needs to agree with the number of check-constraint
161    entries found in this table for each relation.