Updated on 2023-10-23 GMT+08:00

PG_ATTRIBUTE

PG_ATTRIBUTE records information about table columns.

Table 1 PG_ATTRIBUTE columns

Name

Type

Description

attrelid

oid

Table to which a column belongs

attname

name

Column name

atttypid

oid

Column type

attstattarget

integer

Level of details of statistics collected for this column by ANALYZE.

  • The value 0 indicates that no statistics should be collected.
  • A negative value indicates that the system default statistic object is used.
  • 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.

attlen

smallint

Copy of typlen in PG_TYPE of the column's type

attnum

smallint

Number of the column

attndims

integer

Number of dimensions if the column is an array (0 in other cases)

attcacheoff

integer

This column is always -1 on disk. When it is loaded into a row descriptor in the memory, it may be updated to cache the offset of the columns in the row.

atttypmod

integer

Type-specific data supplied at the table creation time (for example, the maximum length of a varchar column). This column is used as the third parameter when passing to type-specific input functions and length coercion functions. The value will generally be -1 for types that do not need ATTTYPMOD.

attbyval

boolean

Copy of typbyval in PG_TYPE of this column's type

attstorage

"char"

Copy of typstorage in PG_TYPE of this column's type

attalign

"char"

Copy of typalign in PG_TYPE of this column's type

attnotnull

boolean

A non-null constraint. It is possible to change this column to enable or disable the constraint.

atthasdef

boolean

This column has a default value, in which case there will be a corresponding entry in the PG_ATTRDEF table that actually defines the value.

attisdropped

boolean

Indicates that this column has been deleted and is no longer valid. A deleted column is still physically present in the table but is ignored by the analyzer, so it cannot be accessed through SQL.

attislocal

boolean

Indicates that this column is locally defined in the relationship. Note that a column can be locally defined and inherited simultaneously.

attcmprmode

tinyint

Compressed modes for a specific column. The compressed mode includes:
  • ATT_CMPR_NOCOMPRESS
  • ATT_CMPR_DELTA
  • ATT_CMPR_DICTIONARY
  • ATT_CMPR_PREFIX
  • ATT_CMPR_NUMSTR

attinhcount

integer

Number of direct ancestors that this column has. A column with an ancestor cannot be dropped nor renamed.

attcollation

oid

Defined collation of a column

attacl

aclitem[]

Permissions for column-level access

attoptions

text[]

Column attribute. Currently, the following attributes are supported:

  • n_distinct: number of distinct values of a column (excluding subtables).
  • n_distinct_inherited: number of distinct values of a column (including subtables).

attfdwoptions

text[]

Column attribute of a foreign table. Currently, dist_fdw, file_fdw, and log_fdw do not use foreign table column attributes.

attinitdefval

bytea

attinitdefval stores the default value expression. ADD COLUMN in the row-store table must use this column.

attkvtype

tinyint

Specifies a key value type for a column. Types include:

0. ATT_KV_UNDEFINED: default value

1. ATT_KV_TAG: dimension

2. ATT_KV_FIELD: indicator

3. ATT_KV_TIMETAG: time column

4. ATT_KV_HIDETAG: hidden distribution column