38.6. attributes
Представление attributes содержит информацию об атрибутах составных типов данных, определённых в базе. (Заметьте, что представление не даёт информацию о столбцах таблицы, которые иногда называются атрибутами в контекстах Postgres Pro.) В нём показываются только те атрибуты, к которым имеет доступ текущий пользователь (являясь владельцем или имея некоторое право для использования типа).
Таблица 38.4. Столбцы attributes
| Имя | Тип данных | Описание |
|---|---|---|
udt_catalog | sql_identifier | Имя базы данных, содержащей тип данных (всегда текущая база) |
udt_schema | sql_identifier | Имя схемы, содержащей тип данных |
udt_name | sql_identifier | Имя типа данных |
attribute_name | sql_identifier | Имя атрибута |
ordinal_position | cardinal_number | Порядковый номер атрибута внутри типа данных (нумерация начинается с 1) |
attribute_default | character_data | Выражение по умолчанию для атрибута |
is_nullable | yes_or_no | YES, если атрибут может содержать NULL, или NO, если он не принимает NULL |
data_type | character_data | Тип данных атрибута, если это встроенный тип, либо ARRAY, если это массив (в этом случае обратитесь к представлению element_types), иначе — USER-DEFINED (в этом случае тип определяется в attribute_udt_name и связанных столбцах). |
character_maximum_length | cardinal_number | Если в data_type указан тип текстовой или битовой строки, это поле задаёт её объявленную максимальную длину; NULL для всех других типов данных, либо если максимальная длина не объявлена. |
character_octet_length | cardinal_number | Если в data_type указан тип символьной строки, это поле задаёт её максимально возможный размер в октетах (байтах); NULL для всех других типов данных. Максимальный размер в октетах зависит от объявленной максимальной длины в символах (см. выше) и от кодировки сервера. |
character_set_catalog | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
character_set_schema | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
character_set_name | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
collation_catalog | sql_identifier | Имя базы данных, содержащей правило сортировки атрибута (это всегда текущая база), либо NULL, если это правило по умолчанию или тип данных атрибута несортируемый |
collation_schema | sql_identifier | Имя схемы, содержащей правило сортировки атрибута, либо NULL, если это правило по умолчанию или тип данных атрибута несортируемый |
collation_name | sql_identifier | Имя правила сортировки атрибута, либо NULL, если это правило по умолчанию или атрибут несортируемый |
numeric_precision | cardinal_number | Если в data_type указан числовой тип, этот столбец содержит точность (объявленную или неявную) типа для этого атрибута. Точность определяет число значащих цифр. Она может выражаться в десятичных (по основанию 10) или двоичных (по основанию 2) цифрах, согласно столбцу numeric_precision_radix. Для всех других типов данных этот столбец содержит NULL. |
numeric_precision_radix | cardinal_number | Если в data_type указан числовой тип, в этом столбце определяется, по какому основанию задаются значения в столбцах numeric_precision и numeric_scale. Возможные варианты: 2 или 10. Для всех других типов данных этот столбец содержит NULL. |
numeric_scale | cardinal_number | Если в data_type указан точный числовой тип, этот столбец содержит масштаб (объявленный или неявный) типа для этого атрибута. Масштаб определяет число значащих цифр справа от десятичной точки. Он может выражаться в десятичных (по основанию 10) или двоичных (по основанию 2) цифрах, согласно столбцу numeric_precision_radix. Для всех других типов данных этот столбец содержит NULL. |
datetime_precision | cardinal_number | Если в data_type указан тип даты, времени, отметки времени или интервала, этот столбец содержит точность (объявленную или неявную) в долях секунды типа этого атрибута, то есть число десятичных цифр, сохраняемых после десятичной точки в значении секунд. Для всех других типов данных этот столбец содержит NULL. |
interval_type | character_data | Если в data_type указан тип интервала, этот столбец определяет, какие поля принимает интервал в этом атрибуте, например: YEAR TO MONTH, DAY TO SECOND и т. д. Если ограничения для полей не заданы (то есть, интервал принимает все поля), и для любых других типов данных это поле содержит NULL. |
interval_precision | cardinal_number | Относится к функциональности, отсутствующей в Postgres Pro (см. поле datetime_precision, определяющее точность в долях секунды для типов интервалов) |
attribute_udt_catalog | sql_identifier | Имя базы данных, в которой определён тип данных атрибута (всегда текущая база) |
attribute_udt_schema | sql_identifier | Имя схемы, в которой определён тип данных атрибута |
attribute_udt_name | sql_identifier | Имя типа данных атрибута |
scope_catalog | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
scope_schema | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
scope_name | sql_identifier | Относится к функциональности, отсутствующей в Postgres Pro |
maximum_cardinality | cardinal_number | Всегда NULL, так как массивы имеют неограниченную максимальную ёмкость в Postgres Pro |
dtd_identifier | sql_identifier | Идентификатор дескриптора типа данных столбца, уникальный среди всех дескрипторов типов, относящихся к таблице. Он в основном полезен для соединения с другими экземплярами таких идентификаторов. (Конкретный формат идентификатора не определён и не гарантируется, что он останется неизменным в будущих версиях.) |
is_derived_reference_attribute | yes_or_no | Относится к функциональности, отсутствующей в Postgres Pro |
Обратитесь также к описанию Раздел 38.16, представлению с похожей структурой, за дополнительной информацией о некоторых столбцах.
38.6. attributes
The view attributes contains information about the attributes of composite data types defined in the database. (Note that the view does not give information about table columns, which are sometimes called attributes in Postgres Pro contexts.) Only those attributes are shown that the current user has access to (by way of being the owner of or having some privilege on the type).
Table 38.4. attributes Columns
| Name | Data Type | Description |
|---|---|---|
udt_catalog | sql_identifier | Name of the database containing the data type (always the current database) |
udt_schema | sql_identifier | Name of the schema containing the data type |
udt_name | sql_identifier | Name of the data type |
attribute_name | sql_identifier | Name of the attribute |
ordinal_position | cardinal_number | Ordinal position of the attribute within the data type (count starts at 1) |
attribute_default | character_data | Default expression of the attribute |
is_nullable | yes_or_no | YES if the attribute is possibly nullable, NO if it is known not nullable. |
data_type | character_data | Data type of the attribute, if it is a built-in type, or ARRAY if it is some array (in that case, see the view element_types), else USER-DEFINED (in that case, the type is identified in attribute_udt_name and associated columns). |
character_maximum_length | cardinal_number | If data_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_length | cardinal_number | If data_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. |
character_set_catalog | sql_identifier | Applies to a feature not available in Postgres Pro |
character_set_schema | sql_identifier | Applies to a feature not available in Postgres Pro |
character_set_name | sql_identifier | Applies to a feature not available in Postgres Pro |
collation_catalog | sql_identifier | Name of the database containing the collation of the attribute (always the current database), null if default or the data type of the attribute is not collatable |
collation_schema | sql_identifier | Name of the schema containing the collation of the attribute, null if default or the data type of the attribute is not collatable |
collation_name | sql_identifier | Name of the collation of the attribute, null if default or the data type of the attribute is not collatable |
numeric_precision | cardinal_number | If data_type identifies a numeric type, this column contains the (declared or implicit) precision of the type for this attribute. 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 numeric_precision_radix. For all other data types, this column is null. |
numeric_precision_radix | cardinal_number | If data_type identifies a numeric type, this column indicates in which base the values in the columns numeric_precision and numeric_scale are expressed. The value is either 2 or 10. For all other data types, this column is null. |
numeric_scale | cardinal_number | If data_type identifies an exact numeric type, this column contains the (declared or implicit) scale of the type for this attribute. 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 numeric_precision_radix. For all other data types, this column is null. |
datetime_precision | cardinal_number | If data_type identifies a date, time, timestamp, or interval type, this column contains the (declared or implicit) fractional seconds precision of the type for this attribute, 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_type | character_data | If data_type identifies an interval type, this column contains the specification which fields the intervals include for this attribute, 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_precision | cardinal_number | Applies to a feature not available in Postgres Pro (see datetime_precision for the fractional seconds precision of interval type attributes) |
attribute_udt_catalog | sql_identifier | Name of the database that the attribute data type is defined in (always the current database) |
attribute_udt_schema | sql_identifier | Name of the schema that the attribute data type is defined in |
attribute_udt_name | sql_identifier | Name of the attribute data type |
scope_catalog | sql_identifier | Applies to a feature not available in Postgres Pro |
scope_schema | sql_identifier | Applies to a feature not available in Postgres Pro |
scope_name | sql_identifier | Applies to a feature not available in Postgres Pro |
maximum_cardinality | cardinal_number | Always null, because arrays always have unlimited maximum cardinality in Postgres Pro |
dtd_identifier | sql_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_derived_reference_attribute | yes_or_no | Applies to a feature not available in Postgres Pro |
See also under Section 38.16, a similarly structured view, for further information on some of the columns.