35.17. columns
columns
The view columns contains information about all table columns (or view columns) in the database.
System columns (ctid, 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).
Column Type Description |
|---|
table_catalog Name of the database containing the table (always the current database) |
table_schema Name of the schema containing the table |
table_name Name of the table |
column_name Name of the column |
ordinal_position Ordinal position of the column within the table (count starts at 1) |
column_default Default expression of the column |
is_nullable
|
data_type Data type of the column, if it is a built-in type, or |
character_maximum_length If |
character_octet_length If |
numeric_precision If |
numeric_precision_radix If |
numeric_scale If |
datetime_precision If |
interval_type If |
interval_precision Applies to a feature not available in PostgreSQL (see |
character_set_catalog Applies to a feature not available in PostgreSQL |
character_set_schema Applies to a feature not available in PostgreSQL |
character_set_name Applies to a feature not available in PostgreSQL |
collation_catalog 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 |
collation_schema Name of the schema containing the collation of the column, null if default or the data type of the column is not collatable |
collation_name Name of the collation of the column, null if default or the data type of the column is not collatable |
domain_catalog If the column has a domain type, the name of the database that the domain is defined in (always the current database), else null. |
domain_schema If the column has a domain type, the name of the schema that the domain is defined in, else null. |
domain_name If the column has a domain type, the name of the domain, else null. |
udt_catalog Name of the database that the column data type (the underlying type of the domain, if applicable) is defined in (always the current database) |
udt_schema Name of the schema that the column data type (the underlying type of the domain, if applicable) is defined in |
udt_name Name of the column data type (the underlying type of the domain, if applicable) |
scope_catalog Applies to a feature not available in PostgreSQL |
scope_schema Applies to a feature not available in PostgreSQL |
scope_name Applies to a feature not available in PostgreSQL |
maximum_cardinality Always null, because arrays always have unlimited maximum cardinality in PostgreSQL |
dtd_identifier 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.) |
is_self_referencing Applies to a feature not available in PostgreSQL |
is_identity If the column is an identity column, then |
identity_generation If the column is an identity column, then |
identity_start If the column is an identity column, then the start value of the internal sequence, else null. |
identity_increment If the column is an identity column, then the increment of the internal sequence, else null. |
identity_maximum If the column is an identity column, then the maximum value of the internal sequence, else null. |
identity_minimum If the column is an identity column, then the minimum value of the internal sequence, else null. |
identity_cycle If the column is an identity column, then |
is_generated If the column is a generated column, then |
generation_expression If the column is a generated column, then the generation expression, else null. |
is_updatable
|
: columns Columns
Since data types can be defined in a variety of ways in SQL, and PostgreSQL contains additional ways to define data types, their representation in the information schema can be somewhat difficult. The column data_type is supposed to identify the underlying built-in type of the column. In PostgreSQL, this means that the type is defined in the system catalog schema pg_catalog. 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 udt_name, udt_schema, and udt_catalog always identify the underlying data type of the column, even if the column is based on a domain. (Since PostgreSQL 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 domain_name, domain_schema, and domain_catalog. If you want to pair up columns with their associated data types and treat domains as separate types, you could write coalesce(domain_name, udt_name), etc.