Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
37.16. columns
Prev UpChapter 37. The Information SchemaHome Next

37.16. columns

The viewcolumns contains information about all table columns (or view columns) in the database. System columns (oid, 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).

Table 37.14. columns Columns

NameData TypeDescription
table_catalogsql_identifierName of the database containing the table (always the current database)
table_schemasql_identifierName of the schema containing the table
table_namesql_identifierName of the table
column_namesql_identifierName of the column
ordinal_positioncardinal_numberOrdinal position of the column within the table (count starts at 1)
column_defaultcharacter_dataDefault expression of the column
is_nullableyes_or_noYES if the column is possibly nullable,NO 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.
data_typecharacter_data Data type of the column, if it is a built-in type, orARRAY if it is some array (in that case, see the viewelement_types), elseUSER-DEFINED (in that case, the type is identified inudt_name 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 indomain_name and associated columns).
character_maximum_lengthcardinal_number Ifdata_type identifies a character or bit string type, the declared maximum length; null for all other data types or if no maximum length was declared.
character_octet_lengthcardinal_number Ifdata_type 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.
numeric_precisioncardinal_number Ifdata_type 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 columnnumeric_precision_radix. For all other data types, this column is null.
numeric_precision_radixcardinal_number Ifdata_type identifies a numeric type, this column indicates in which base the values in the columnsnumeric_precision andnumeric_scale are expressed. The value is either 2 or 10. For all other data types, this column is null.
numeric_scalecardinal_number Ifdata_type 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 columnnumeric_precision_radix. For all other data types, this column is null.
datetime_precisioncardinal_number Ifdata_type 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.
interval_typecharacter_data Ifdata_type identifies an interval type, this column contains the specification which fields the intervals include for this column, e.g.,YEAR TO MONTH,DAY TO SECOND, etc. If no field restrictions were specified (that is, the interval accepts all fields), and for all other data types, this field is null.
interval_precisioncardinal_number Applies to a feature not available inPostgreSQL (seedatetime_precision for the fractional seconds precision of interval type columns)
character_set_catalogsql_identifierApplies to a feature not available inPostgreSQL
character_set_schemasql_identifierApplies to a feature not available inPostgreSQL
character_set_namesql_identifierApplies to a feature not available inPostgreSQL
collation_catalogsql_identifier 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_schemasql_identifier Name of the schema containing the collation of the column, null if default or the data type of the column is not collatable
collation_namesql_identifier Name of the collation of the column, null if default or the data type of the column is not collatable
domain_catalogsql_identifier 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_schemasql_identifier If the column has a domain type, the name of the schema that the domain is defined in, else null.
domain_namesql_identifierIf the column has a domain type, the name of the domain, else null.
udt_catalogsql_identifier 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_schemasql_identifier Name of the schema that the column data type (the underlying type of the domain, if applicable) is defined in
udt_namesql_identifier Name of the column data type (the underlying type of the domain, if applicable)
scope_catalogsql_identifierApplies to a feature not available inPostgreSQL
scope_schemasql_identifierApplies to a feature not available inPostgreSQL
scope_namesql_identifierApplies to a feature not available inPostgreSQL
maximum_cardinalitycardinal_numberAlways null, because arrays always have unlimited maximum cardinality inPostgreSQL
dtd_identifiersql_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_referencingyes_or_noApplies to a feature not available inPostgreSQL
is_identityyes_or_no If the column is an identity column, thenYES, elseNO.
identity_generationcharacter_data If the column is an identity column, thenALWAYS orBY DEFAULT, reflecting the definition of the column.
identity_startcharacter_data If the column is an identity column, then the start value of the internal sequence, else null.
identity_incrementcharacter_data If the column is an identity column, then the increment of the internal sequence, else null.
identity_maximumcharacter_data If the column is an identity column, then the maximum value of the internal sequence, else null.
identity_minimumcharacter_data If the column is an identity column, then the minimum value of the internal sequence, else null.
identity_cycleyes_or_no If the column is an identity column, thenYES if the internal sequence cycles orNO if it does not; otherwise null.
is_generatedcharacter_dataApplies to a feature not available inPostgreSQL
generation_expressioncharacter_dataApplies to a feature not available inPostgreSQL
is_updatableyes_or_noYES if the column is updatable,NO if not (Columns in base tables are always updatable, columns in views not necessarily)

Since data types can be defined in a variety of ways in SQL, andPostgreSQL contains additional ways to define data types, their representation in the information schema can be somewhat difficult. The columndata_type is supposed to identify the underlying built-in type of the column. InPostgreSQL, this means that the type is defined in the system catalog schemapg_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 columnsudt_name,udt_schema, andudt_catalog always identify the underlying data type of the column, even if the column is based on a domain. (SincePostgreSQL 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 columnsdomain_name,domain_schema, anddomain_catalog. If you want to pair up columns with their associated data types and treat domains as separate types, you could writecoalesce(domain_name, udt_name), etc.


Prev Up Next
37.15. column_udt_usage Home 37.17. constraint_column_usage
epubpdf
Go to PostgreSQL 11
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp