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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>37.17. columns</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="infoschema-column-udt-usage.html" title="37.16. column_udt_usage" /><link rel="next" href="infoschema-constraint-column-usage.html" title="37.18. constraint_column_usage" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">37.17. <code class="literal">columns</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="infoschema-column-udt-usage.html" title="37.16. column_udt_usage">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="information-schema.html" title="Chapter 37. The Information Schema">Up</a></td><th width="60%" align="center">Chapter 37. The Information Schema</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="infoschema-constraint-column-usage.html" title="37.18. constraint_column_usage">Next</a></td></tr></table><hr /></div><div class="sect1" id="INFOSCHEMA-COLUMNS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">37.17. <code class="literal">columns</code> <a href="#INFOSCHEMA-COLUMNS" class="id_link">#</a></h2></div></div></div><p>
The view <code class="literal">columns</code> contains information about all
table columns (or view columns) in the database. System columns
(<code class="literal">ctid</code>, etc.) are not included. Only those columns are
shown that the current user has access to (by way of being the
owner or having some privilege).
</p><div class="table" id="id-1.7.6.21.3"><p class="title"><strong>Table 37.15. <code class="structname">columns</code> Columns</strong></p><div class="table-contents"><table class="table" summary="columns Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">
Column Type
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">table_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the database containing the table (always the current database)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">table_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the schema containing the table
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">table_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the table
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">column_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the column
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">ordinal_position</code> <code class="type">cardinal_number</code>
</p>
<p>
Ordinal position of the column within the table (count starts at 1)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">column_default</code> <code class="type">character_data</code>
</p>
<p>
Default expression of the column
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">is_nullable</code> <code class="type">yes_or_no</code>
</p>
<p>
<code class="literal">YES</code> if the column is possibly nullable,
<code class="literal">NO</code> if it is known not nullable. A not-null
constraint is one way a column can be known not nullable, but
there can be others.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">data_type</code> <code class="type">character_data</code>
</p>
<p>
Data type of the column, if it is a built-in type, or
<code class="literal">ARRAY</code> if it is some array (in that case, see
the view <code class="literal">element_types</code>), else
<code class="literal">USER-DEFINED</code> (in that case, the type is
identified in <code class="literal">udt_name</code> and associated
columns). If the column is based on a domain, this column
refers to the type underlying the domain (and the domain is
identified in <code class="literal">domain_name</code> and associated
columns).
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">character_maximum_length</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies a character or bit
string type, the declared maximum length; null for all other
data types or if no maximum length was declared.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">character_octet_length</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies a character type,
the maximum possible length in octets (bytes) of a datum; null
for all other data types. The maximum octet length depends on
the declared character maximum length (see above) and the
server encoding.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">numeric_precision</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies a numeric type, this
column contains the (declared or implicit) precision of the
type for this column. The precision indicates the number of
significant digits. It can be expressed in decimal (base 10)
or binary (base 2) terms, as specified in the column
<code class="literal">numeric_precision_radix</code>. For all other data
types, this column is null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">numeric_precision_radix</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies a numeric type, this
column indicates in which base the values in the columns
<code class="literal">numeric_precision</code> and
<code class="literal">numeric_scale</code> are expressed. The value is
either 2 or 10. For all other data types, this column is null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">numeric_scale</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies an exact numeric
type, this column contains the (declared or implicit) scale of
the type for this column. The scale indicates the number of
significant digits to the right of the decimal point. It can
be expressed in decimal (base 10) or binary (base 2) terms, as
specified in the column
<code class="literal">numeric_precision_radix</code>. For all other data
types, this column is null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">datetime_precision</code> <code class="type">cardinal_number</code>
</p>
<p>
If <code class="literal">data_type</code> identifies a date, time,
timestamp, or interval type, this column contains the (declared
or implicit) fractional seconds precision of the type for this
column, that is, the number of decimal digits maintained
following the decimal point in the seconds value. For all
other data types, this column is null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">interval_type</code> <code class="type">character_data</code>
</p>
<p>
If <code class="literal">data_type</code> identifies an interval type,
this column contains the specification which fields the
intervals include for this column, e.g., <code class="literal">YEAR TO
MONTH</code>, <code class="literal">DAY TO SECOND</code>, etc. If no
field restrictions were specified (that is, the interval
accepts all fields), and for all other data types, this field
is null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">interval_precision</code> <code class="type">cardinal_number</code>
</p>
<p>
Applies to a feature not available
in <span class="productname">PostgreSQL</span>
(see <code class="literal">datetime_precision</code> for the fractional
seconds precision of interval type columns)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">character_set_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">character_set_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">character_set_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">collation_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the database containing the collation of the column
(always the current database), null if default or the data type
of the column is not collatable
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">collation_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the schema containing the collation of the column, null
if default or the data type of the column is not collatable
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">collation_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the collation of the column, null if default or the
data type of the column is not collatable
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">domain_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
If the column has a domain type, the name of the database that
the domain is defined in (always the current database), else
null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">domain_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
If the column has a domain type, the name of the schema that
the domain is defined in, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">domain_name</code> <code class="type">sql_identifier</code>
</p>
<p>
If the column has a domain type, the name of the domain, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">udt_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the database that the column data type (the underlying
type of the domain, if applicable) is defined in (always the
current database)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">udt_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the schema that the column data type (the underlying
type of the domain, if applicable) is defined in
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">udt_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Name of the column data type (the underlying type of the
domain, if applicable)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">scope_catalog</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">scope_schema</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">scope_name</code> <code class="type">sql_identifier</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">maximum_cardinality</code> <code class="type">cardinal_number</code>
</p>
<p>
Always null, because arrays always have unlimited maximum cardinality in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">dtd_identifier</code> <code class="type">sql_identifier</code>
</p>
<p>
An identifier of the data type descriptor of the column, unique
among the data type descriptors pertaining to the table. This
is mainly useful for joining with other instances of such
identifiers. (The specific format of the identifier is not
defined and not guaranteed to remain the same in future
versions.)
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">is_self_referencing</code> <code class="type">yes_or_no</code>
</p>
<p>
Applies to a feature not available in <span class="productname">PostgreSQL</span>
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">is_identity</code> <code class="type">yes_or_no</code>
</p>
<p>
If the column is an identity column, then <code class="literal">YES</code>,
else <code class="literal">NO</code>.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_generation</code> <code class="type">character_data</code>
</p>
<p>
If the column is an identity column, then <code class="literal">ALWAYS</code>
or <code class="literal">BY DEFAULT</code>, reflecting the definition of the
column.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_start</code> <code class="type">character_data</code>
</p>
<p>
If the column is an identity column, then the start value of the
internal sequence, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_increment</code> <code class="type">character_data</code>
</p>
<p>
If the column is an identity column, then the increment of the internal
sequence, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_maximum</code> <code class="type">character_data</code>
</p>
<p>
If the column is an identity column, then the maximum value of the
internal sequence, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_minimum</code> <code class="type">character_data</code>
</p>
<p>
If the column is an identity column, then the minimum value of the
internal sequence, else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">identity_cycle</code> <code class="type">yes_or_no</code>
</p>
<p>
If the column is an identity column, then <code class="literal">YES</code> if the
internal sequence cycles or <code class="literal">NO</code> if it does not;
otherwise null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">is_generated</code> <code class="type">character_data</code>
</p>
<p>
If the column is a generated column, then <code class="literal">ALWAYS</code>,
else <code class="literal">NEVER</code>.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">generation_expression</code> <code class="type">character_data</code>
</p>
<p>
If the column is a generated column, then the generation expression,
else null.
</p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
<code class="structfield">is_updatable</code> <code class="type">yes_or_no</code>
</p>
<p>
<code class="literal">YES</code> if the column is updatable,
<code class="literal">NO</code> if not (Columns in base tables are always
updatable, columns in views not necessarily)
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
Since data types can be defined in a variety of ways in SQL, and
<span class="productname">PostgreSQL</span> contains additional ways to
define data types, their representation in the information schema
can be somewhat difficult. The column <code class="literal">data_type</code>
is supposed to identify the underlying built-in type of the column.
In <span class="productname">PostgreSQL</span>, this means that the type
is defined in the system catalog schema
<code class="literal">pg_catalog</code>. This column might be useful if the
application can handle the well-known built-in types specially (for
example, format the numeric types differently or use the data in
the precision columns). The columns <code class="literal">udt_name</code>,
<code class="literal">udt_schema</code>, and <code class="literal">udt_catalog</code>
always identify the underlying data type of the column, even if the
column is based on a domain. (Since
<span class="productname">PostgreSQL</span> treats built-in types like
user-defined types, built-in types appear here as well. This is an
extension of the SQL standard.) These columns should be used if an
application wants to process data differently according to the
type, because in that case it wouldn't matter if the column is
really based on a domain. If the column is based on a domain, the
identity of the domain is stored in the columns
<code class="literal">domain_name</code>, <code class="literal">domain_schema</code>,
and <code class="literal">domain_catalog</code>. If you want to pair up
columns with their associated data types and treat domains as
separate types, you could write <code class="literal">coalesce(domain_name,
udt_name)</code>, etc.
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="infoschema-column-udt-usage.html" title="37.16. column_udt_usage">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="information-schema.html" title="Chapter 37. The Information Schema">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="infoschema-constraint-column-usage.html" title="37.18. constraint_column_usage">Next</a></td></tr><tr><td width="40%" align="left" valign="top">37.16. <code class="literal">column_udt_usage</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 37.18. <code class="literal">constraint_column_usage</code></td></tr></table></div></body></html>
|