File: catalog-pg-constraint.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (155 lines) | stat: -rw-r--r-- 6,205 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>42.13.pg_constraint</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="catalogs.html" title="Chapter42.System Catalogs">
<link rel="prev" href="catalog-pg-class.html" title="42.12.pg_class">
<link rel="next" href="catalog-pg-conversion.html" title="42.14.pg_conversion">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="catalog-pg-constraint"></a>42.13.<code class="structname">pg_constraint</code></h2></div></div></div>
<a name="id824303"></a><p>   The catalog <code class="structname">pg_constraint</code> stores check, primary key, unique, 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
   <code class="structname">pg_attribute</code> catalog.
  </p>
<p>   Check constraints on domains are stored here, too.
  </p>
<div class="table">
<a name="id824333"></a><p class="title"><b>Table42.13.<code class="structname">pg_constraint</code> Columns</b></p>
<div class="table-contents"><table summary="pg_constraint Columns" border="1">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>References</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><code class="structfield">conname</code></td>
<td><code class="type">name</code></td>
<td></td>
<td>Constraint name (not necessarily unique!)</td>
</tr>
<tr>
<td><code class="structfield">connamespace</code></td>
<td><code class="type">oid</code></td>
<td><code class="literal"><a href="catalog-pg-namespace.html" title="42.23.pg_namespace"><code class="structname">pg_namespace</code></a>.oid</code></td>
<td>       The OID of the namespace that contains this constraint
      </td>
</tr>
<tr>
<td><code class="structfield">contype</code></td>
<td><code class="type">char</code></td>
<td></td>
<td>        <code class="literal">c</code> = check constraint,
        <code class="literal">f</code> = foreign key constraint,
        <code class="literal">p</code> = primary key constraint,
        <code class="literal">u</code> = unique constraint
      </td>
</tr>
<tr>
<td><code class="structfield">condeferrable</code></td>
<td><code class="type">bool</code></td>
<td></td>
<td>Is the constraint deferrable?</td>
</tr>
<tr>
<td><code class="structfield">condeferred</code></td>
<td><code class="type">bool</code></td>
<td></td>
<td>Is the constraint deferred by default?</td>
</tr>
<tr>
<td><code class="structfield">conrelid</code></td>
<td><code class="type">oid</code></td>
<td><code class="literal"><a href="catalog-pg-class.html" title="42.12.pg_class"><code class="structname">pg_class</code></a>.oid</code></td>
<td>The table this constraint is on; 0 if not a table constraint</td>
</tr>
<tr>
<td><code class="structfield">contypid</code></td>
<td><code class="type">oid</code></td>
<td><code class="literal"><a href="catalog-pg-type.html" title="42.33.pg_type"><code class="structname">pg_type</code></a>.oid</code></td>
<td>The domain this constraint is on; 0 if not a domain constraint</td>
</tr>
<tr>
<td><code class="structfield">confrelid</code></td>
<td><code class="type">oid</code></td>
<td><code class="literal"><a href="catalog-pg-class.html" title="42.12.pg_class"><code class="structname">pg_class</code></a>.oid</code></td>
<td>If a foreign key, the referenced table; else 0</td>
</tr>
<tr>
<td><code class="structfield">confupdtype</code></td>
<td><code class="type">char</code></td>
<td></td>
<td>Foreign key update action code</td>
</tr>
<tr>
<td><code class="structfield">confdeltype</code></td>
<td><code class="type">char</code></td>
<td></td>
<td>Foreign key deletion action code</td>
</tr>
<tr>
<td><code class="structfield">confmatchtype</code></td>
<td><code class="type">char</code></td>
<td></td>
<td>Foreign key match type</td>
</tr>
<tr>
<td><code class="structfield">conkey</code></td>
<td><code class="type">int2[]</code></td>
<td><code class="literal"><a href="catalog-pg-attribute.html" title="42.7.pg_attribute"><code class="structname">pg_attribute</code></a>.attnum</code></td>
<td>If a table constraint, list of columns which the constraint constrains</td>
</tr>
<tr>
<td><code class="structfield">confkey</code></td>
<td><code class="type">int2[]</code></td>
<td><code class="literal"><a href="catalog-pg-attribute.html" title="42.7.pg_attribute"><code class="structname">pg_attribute</code></a>.attnum</code></td>
<td>If a foreign key, list of the referenced columns</td>
</tr>
<tr>
<td><code class="structfield">conbin</code></td>
<td><code class="type">text</code></td>
<td></td>
<td>If a check constraint, an internal representation of the expression</td>
</tr>
<tr>
<td><code class="structfield">consrc</code></td>
<td><code class="type">text</code></td>
<td></td>
<td>If a check constraint, a human-readable representation of the expression</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>    <code class="structfield">consrc</code> is not updated when referenced objects
    change; for example, it won't track renaming of columns.  Rather than
    relying on this field, it's best to use <code class="function">pg_get_constraintdef()</code>
    to extract the definition of a check constraint.
   </p>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>    <code class="literal">pg_class.relchecks</code> needs to agree with the
    number of check-constraint entries found in this table for the
    given relation.
   </p>
</div>
</div></body>
</html>