4 The view columns contains information about all table columns (or view
5 columns) in the database. System columns (ctid, etc.) are not included.
6 Only those columns are shown that the current user has access to (by
7 way of being the owner or having some privilege).
9 Table 35.15. columns Columns
15 table_catalog sql_identifier
17 Name of the database containing the table (always the current database)
19 table_schema sql_identifier
21 Name of the schema containing the table
23 table_name sql_identifier
27 column_name sql_identifier
31 ordinal_position cardinal_number
33 Ordinal position of the column within the table (count starts at 1)
35 column_default character_data
37 Default expression of the column
41 YES if the column is possibly nullable, NO if it is known not nullable.
42 A not-null constraint is one way a column can be known not nullable,
43 but there can be others.
45 data_type character_data
47 Data type of the column, if it is a built-in type, or ARRAY if it is
48 some array (in that case, see the view element_types), else
49 USER-DEFINED (in that case, the type is identified in udt_name and
50 associated columns). If the column is based on a domain, this column
51 refers to the type underlying the domain (and the domain is identified
52 in domain_name and associated columns).
54 character_maximum_length cardinal_number
56 If data_type identifies a character or bit string type, the declared
57 maximum length; null for all other data types or if no maximum length
60 character_octet_length cardinal_number
62 If data_type identifies a character type, the maximum possible length
63 in octets (bytes) of a datum; null for all other data types. The
64 maximum octet length depends on the declared character maximum length
65 (see above) and the server encoding.
67 numeric_precision cardinal_number
69 If data_type identifies a numeric type, this column contains the
70 (declared or implicit) precision of the type for this column. The
71 precision indicates the number of significant digits. It can be
72 expressed in decimal (base 10) or binary (base 2) terms, as specified
73 in the column numeric_precision_radix. For all other data types, this
76 numeric_precision_radix cardinal_number
78 If data_type identifies a numeric type, this column indicates in which
79 base the values in the columns numeric_precision and numeric_scale are
80 expressed. The value is either 2 or 10. For all other data types, this
83 numeric_scale cardinal_number
85 If data_type identifies an exact numeric type, this column contains the
86 (declared or implicit) scale of the type for this column. The scale
87 indicates the number of significant digits to the right of the decimal
88 point. It can be expressed in decimal (base 10) or binary (base 2)
89 terms, as specified in the column numeric_precision_radix. For all
90 other data types, this column is null.
92 datetime_precision cardinal_number
94 If data_type identifies a date, time, timestamp, or interval type, this
95 column contains the (declared or implicit) fractional seconds precision
96 of the type for this column, that is, the number of decimal digits
97 maintained following the decimal point in the seconds value. For all
98 other data types, this column is null.
100 interval_type character_data
102 If data_type identifies an interval type, this column contains the
103 specification which fields the intervals include for this column, e.g.,
104 YEAR TO MONTH, DAY TO SECOND, etc. If no field restrictions were
105 specified (that is, the interval accepts all fields), and for all other
106 data types, this field is null.
108 interval_precision cardinal_number
110 Applies to a feature not available in PostgreSQL (see
111 datetime_precision for the fractional seconds precision of interval
114 character_set_catalog sql_identifier
116 Applies to a feature not available in PostgreSQL
118 character_set_schema sql_identifier
120 Applies to a feature not available in PostgreSQL
122 character_set_name sql_identifier
124 Applies to a feature not available in PostgreSQL
126 collation_catalog sql_identifier
128 Name of the database containing the collation of the column (always the
129 current database), null if default or the data type of the column is
132 collation_schema sql_identifier
134 Name of the schema containing the collation of the column, null if
135 default or the data type of the column is not collatable
137 collation_name sql_identifier
139 Name of the collation of the column, null if default or the data type
140 of the column is not collatable
142 domain_catalog sql_identifier
144 If the column has a domain type, the name of the database that the
145 domain is defined in (always the current database), else null.
147 domain_schema sql_identifier
149 If the column has a domain type, the name of the schema that the domain
150 is defined in, else null.
152 domain_name sql_identifier
154 If the column has a domain type, the name of the domain, else null.
156 udt_catalog sql_identifier
158 Name of the database that the column data type (the underlying type of
159 the domain, if applicable) is defined in (always the current database)
161 udt_schema sql_identifier
163 Name of the schema that the column data type (the underlying type of
164 the domain, if applicable) is defined in
166 udt_name sql_identifier
168 Name of the column data type (the underlying type of the domain, if
171 scope_catalog sql_identifier
173 Applies to a feature not available in PostgreSQL
175 scope_schema sql_identifier
177 Applies to a feature not available in PostgreSQL
179 scope_name sql_identifier
181 Applies to a feature not available in PostgreSQL
183 maximum_cardinality cardinal_number
185 Always null, because arrays always have unlimited maximum cardinality
188 dtd_identifier sql_identifier
190 An identifier of the data type descriptor of the column, unique among
191 the data type descriptors pertaining to the table. This is mainly
192 useful for joining with other instances of such identifiers. (The
193 specific format of the identifier is not defined and not guaranteed to
194 remain the same in future versions.)
196 is_self_referencing yes_or_no
198 Applies to a feature not available in PostgreSQL
200 is_identity yes_or_no
202 If the column is an identity column, then YES, else NO.
204 identity_generation character_data
206 If the column is an identity column, then ALWAYS or BY DEFAULT,
207 reflecting the definition of the column.
209 identity_start character_data
211 If the column is an identity column, then the start value of the
212 internal sequence, else null.
214 identity_increment character_data
216 If the column is an identity column, then the increment of the internal
219 identity_maximum character_data
221 If the column is an identity column, then the maximum value of the
222 internal sequence, else null.
224 identity_minimum character_data
226 If the column is an identity column, then the minimum value of the
227 internal sequence, else null.
229 identity_cycle yes_or_no
231 If the column is an identity column, then YES if the internal sequence
232 cycles or NO if it does not; otherwise null.
234 is_generated character_data
236 If the column is a generated column, then ALWAYS, else NEVER.
238 generation_expression character_data
240 If the column is a generated column, then the generation expression,
243 is_updatable yes_or_no
245 YES if the column is updatable, NO if not (Columns in base tables are
246 always updatable, columns in views not necessarily)
248 Since data types can be defined in a variety of ways in SQL, and
249 PostgreSQL contains additional ways to define data types, their
250 representation in the information schema can be somewhat difficult. The
251 column data_type is supposed to identify the underlying built-in type
252 of the column. In PostgreSQL, this means that the type is defined in
253 the system catalog schema pg_catalog. This column might be useful if
254 the application can handle the well-known built-in types specially (for
255 example, format the numeric types differently or use the data in the
256 precision columns). The columns udt_name, udt_schema, and udt_catalog
257 always identify the underlying data type of the column, even if the
258 column is based on a domain. (Since PostgreSQL treats built-in types
259 like user-defined types, built-in types appear here as well. This is an
260 extension of the SQL standard.) These columns should be used if an
261 application wants to process data differently according to the type,
262 because in that case it wouldn't matter if the column is really based
263 on a domain. If the column is based on a domain, the identity of the
264 domain is stored in the columns domain_name, domain_schema, and
265 domain_catalog. If you want to pair up columns with their associated
266 data types and treat domains as separate types, you could write
267 coalesce(domain_name, udt_name), etc.