↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

System Catalogs / System catalogs

pg_attribute

Read the PG 18 manual

The catalog pg_attribute stores information about table columns.

Reading PG 18current·documented in 24 of 24 versions, 7.4 to 20

Kind
System catalogs
Columns in this snapshot
25
Definition source
English manual
Metadata snapshot
18.6

Columns 25

As listed in the PostgreSQL 18 manual.

ColumnTypeDescription / reference
attrelidoidNOT NULLThe table this column belongs to
pg_class.oid
attnamenameNOT NULLThe column name
atttypidoidNOT NULLThe data type of this column (zero for a dropped column)
pg_type.oid
attlenint2NOT NULLA copy of pg_type.typlen of this column's type
attnumint2NOT NULLThe number of the column. Ordinary columns are numbered from 1 up. System columns, such as ctid, have (arbitrary) negative numbers.
atttypmodint4NOT NULLatttypmod records type-specific data supplied at table creation time (for example, the maximum length of a varchar column). It is passed to type-specific input functions and length coercion functions. The value will generally be -1 for types that do not need atttypmod.
attndimsint2NOT NULLNumber 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”.)
attbyvalboolNOT NULLA copy of pg_type.typbyval of this column's type
attaligncharNOT NULLA copy of pg_type.typalign of this column's type
attstoragecharNOT NULLNormally a copy of pg_type.typstorage of this column's type. For TOAST-able data types, this can be altered after column creation to control storage policy.
attcompressioncharNOT NULLThe current compression method of the column. Typically this is '\0' to specify use of the current default setting (see default_toast_compression). Otherwise, 'p' selects pglz compression, while 'l' selects LZ4 compression. However, this field is ignored whenever attstorage does not allow compression.
attnotnullboolNOT NULLThis column has a (possibly invalid) not-null constraint.
atthasdefboolNOT NULLThis 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 expression. (Check attgenerated to determine whether this is a default or a generation expression.)
atthasmissingboolNOT NULLThis 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 DEFAULT value after the row is created. The actual value used is stored in the attmissingval column.
attidentitycharNOT NULLIf a zero byte (''), then not an identity column. Otherwise, a = generated always, d = generated by default.
attgeneratedcharNOT NULLIf a zero byte (''), then not a generated column. Otherwise, s = stored, v = virtual. A stored generated column is physically stored like a normal column. A virtual generated column is physically stored as a null value, with the actual value being computed at run time.
attisdroppedboolNOT NULLThis 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.
attislocalboolNOT NULLThis column is defined locally in the relation. Note that a column can be locally defined and inherited simultaneously.
attinhcountint2NOT NULLThe number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed.
attcollationoidNOT NULLThe defined collation of the column, or zero if the column is not of a collatable data type
pg_collation.oid
attstattargetint2attstattarget controls the level of detail of statistics accumulated for this column by ANALYZE. A zero value indicates that no statistics should be collected. A null value says to use the system default statistics target. The exact meaning of positive values is data type-dependent. For scalar data types, attstattarget is both the target number of “most common values” to collect, and the target number of histogram bins to create.
attaclaclitem[]Column-level access privileges, if any have been granted specifically on this column
attoptionstext[]Attribute-level options, as “keyword=value” strings
attfdwoptionstext[]Attribute-level foreign data wrapper options, as “keyword=value” strings
attmissingvalanyarrayThis 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 DEFAULT value after the row is created. The value is only used when atthasmissing is true. If there is no value the column is null.
Column history across versions
Version history 15
  1. 17 → 18 changed
  2. 16 → 17 changed
  3. 15 → 16 changed
  4. 13 → 14 changed
  5. 11 → 12 changed
  6. 10 → 11 changed
  7. 9.6 → 10 changed
  8. 9.4 → 9.5 reworded
  9. 9.1 → 9.2 changed
  10. 9.0 → 9.1 changed
  11. 8.4 → 9.0 changed
  12. 8.3 → 8.4 changed
  13. 8.2 → 8.3 reworded
  14. 8.1 → 8.2 reworded
  15. 7.4 → 8.0 changed

Definition snapshot: english-manuals:c9787bd15fe88cbb9f99098096e… · English manual source