pg_attribute #
The catalog pg_attribute stores information about
table columns. There will be exactly one
pg_attribute row for every column in every
table in the database. (There will also be attribute entries for
indexes, and indeed all objects that have
pg_class
entries.)
The term attribute is equivalent to column and is used for historical reasons.
Table 52.7. pg_attribute Columns
Column Type Description |
|---|
The table this column belongs to |
The column name |
The data type of this column (zero for a dropped column) |
A copy of |
The number of the column. Ordinary columns are numbered from 1
up. System columns, such as |
|
An attribute's version is set when the column is added and updated to a larger value whenever the attribute's, or a preceding attribute's, definition changes in a possibly incompatible way. It is used to detect accesses to composite datums that are incompatible with the current definition. The value is zero for attributes that are not versioned, such as those of system catalogs and of relations without a row type, or attributes of relations created in an earlier version that have been migrated via pg_upgrade from a version that did not maintain attribute versions. |
Number of dimensions, if the column is an array type; otherwise 0. (Presently, the number of dimensions of an array is not enforced, so any nonzero value effectively means “it's an array”.) |
A copy of |
A copy of |
Normally a copy of |
The current compression method of the column. Typically this is
|
This column has a (possibly invalid) not-null constraint. |
This column has a default expression or generation expression, in which
case there will be a corresponding entry in the
|
This column has a value which is used where the column is entirely
missing from the row, as happens when a column is added with a
non-volatile |
If a zero byte ( |
If a zero byte ( |
This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL. |
This column is defined locally in the relation. Note that a column can be locally defined and inherited simultaneously. |
The number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed. |
The defined collation of the column, or zero if the column is not of a collatable data type |
|
Column-level access privileges, if any have been granted specifically on this column |
Attribute-level options, as “keyword=value” strings. Can
also contain some internal options prefixed with
|
Attribute-level foreign data wrapper options, as “keyword=value” strings |
This column has a one element array containing the value used when the
column is entirely missing from the row, as happens when the column is
added with a non-volatile |
In a dropped column's pg_attribute entry,
atttypid is reset to zero, but
attlen and the other fields copied from
pg_type are still valid. This arrangement is needed
to cope with the situation where the dropped column's data type was
later dropped, and so there is no pg_type row anymore.
attlen and the other fields can be used
to interpret the contents of a row of the table.