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

NameData TypeDescription
udt_catalogsql_identifierName of the database containing the data type (always the current database)
udt_schemasql_identifierName of the schema containing the data type
udt_namesql_identifierName of the data type
attribute_namesql_identifierName of the attribute
ordinal_positioncardinal_numberOrdinal position of the attribute within the data type (count starts at 1)
attribute_defaultcharacter_dataDefault expression of the attribute
is_nullableyes_or_noYES if the attribute is possibly nullable, NO if it is known not nullable.
data_typecharacter_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_lengthcardinal_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_lengthcardinal_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_catalogsql_identifierApplies to a feature not available in Postgres Pro
character_set_schemasql_identifierApplies to a feature not available in Postgres Pro
character_set_namesql_identifierApplies to a feature not available in Postgres Pro
collation_catalogsql_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_schemasql_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_namesql_identifier Name of the collation of the attribute, null if default or the data type of the attribute is not collatable
numeric_precisioncardinal_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_radixcardinal_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_scalecardinal_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_precisioncardinal_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_typecharacter_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_precisioncardinal_number Applies to a feature not available in Postgres Pro (see datetime_precision for the fractional seconds precision of interval type attributes)
attribute_udt_catalogsql_identifier Name of the database that the attribute data type is defined in (always the current database)
attribute_udt_schemasql_identifier Name of the schema that the attribute data type is defined in
attribute_udt_namesql_identifier Name of the attribute data type
scope_catalogsql_identifierApplies to a feature not available in Postgres Pro
scope_schemasql_identifierApplies to a feature not available in Postgres Pro
scope_namesql_identifierApplies to a feature not available in Postgres Pro
maximum_cardinalitycardinal_numberAlways null, because arrays always have unlimited maximum cardinality in Postgres Pro
dtd_identifiersql_identifier An identifier of the data type descriptor of the attribute, unique among the data type descriptors pertaining to the composite type. 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_attributeyes_or_noApplies to a feature not available in Postgres Pro

See also under Section 38.17, a similarly structured view, for further information on some of the columns.