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.
| Column | Type | References | Description |
|---|---|---|---|
attrelid |
oid |
pg_class.oid |
The table this column belongs to |
attname |
name |
— |
The column name |
atttypid |
oid |
pg_type.oid |
The data type of this column |
attstattarget |
integer |
— |
Controls the level of detail of statistics accumulated for this column by |
attlen |
int2 |
— |
A copy of |
attnum |
int2 |
— |
The number of the column.
Ordinary columns are numbered from 1 up.
System columns, such as |
attndims |
integer |
— |
Number of dimensions, if the column is an array type; otherwise |
attcacheoff |
integer |
— |
Always |
atttypmod |
integer |
— |
Records type-specific data supplied at table creation time (for example, the maximum length of a |
attbyval |
boolean |
— |
A copy of |
attstorage |
char |
— |
Normally a copy of |
attalign |
char |
— |
A copy of |
attnotnull |
boolean |
— |
This represents a not-null constraint. It is possible to change this column to activate or deactivate the constraint |
atthasdef |
boolean |
— |
This column has a default value, in which case there will be a corresponding entry in the |
attisdropped |
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 |
attislocal |
boolean |
— |
This column is defined locally in the relation. Note that a column may be locally defined and inherited simultaneously |
attinhcount |
integer |
— |
The number of direct descendants this column has. A column with a nonzero number of descendants cannot be dropped nor renamed |
attcollation |
oid |
pg_collation.oid |
The defined collation of the column, or |
attacl |
aclitem[] |
— |
Column-level access privileges, if any, have been granted specifically on this column |
attoptions |
text[] |
— |
Attribute-level options, as |
attfdwoptions |
text[] |
— |
Attribute-level foreign data wrapper options, as |