pg_attribute
pg_attribute#
The pg_attribute
table 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 all objects that have pg_class
entries.) The term attribute is equivalent to column.
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 address 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
column |
type |
references |
description |
---|---|---|---|
|
oid |
pg_class.oid |
The table this column belongs to. |
|
name |
The column name. |
|
|
oid |
pg_type.oid |
The data type of this column. |
|
integer |
Controls the level of detail of statistics accumulated for this column by |
|
|
smallint |
A copy of |
|
|
smallint |
The number of the column. Ordinary columns are numbered from 1 up. System columns, such as ctid, have |
|
|
integer |
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 is an array.) |
|
|
integer |
Always -1 in storage, but when loaded into a row descriptor in memory this may be updated to cache the offset of the attribute within the row. |
|
|
integer |
Records type-specific data supplied at table creation time (for example, the maximum length of a |
|
|
boolean |
A copy of |
|
|
char |
Normally a copy of |
|
|
char |
A copy of |
|
|
boolean |
This represents a not-null constraint. |
|
|
boolean |
This column has a default expression or generation expression, in which case there will be a corresponding entry in the pg_attrdef catalog that actually defines the value. (Check |
|
|
boolean |
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 |
|
|
char |
If a zero byte (‘’), then not an identity column. Otherwise, a = generated always, d = generated by default. |
|
|
char |
If a zero byte (‘’), then not a generated column. Otherwise, s = stored. (Other values might be added in the future.) |
|
|
boolean |
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. |
|
|
boolean |
This column is defined locally in the relation. Note that a column may be locally defined and inherited simultaneously. |
|
|
integer |
The number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed. |
|
|
oid |
pg_collation.oid |
The defined collation of the column, or zero if the is not of a collatable data type. |
|
aclitem[] |
Column-level access privileges, if any have been granted specifically on this column. |
|
|
text[] |
Attribute-level options, as “keyword=value” strings. |
|
|
text[] |
Attribute-level foreign data wrapper options, as “keyword=value” strings. |
|
|
anyarray |
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 |