Updated on 2024-08-20 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 12.2.15.78 PG_TYPE of the column 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 set to –1 on disks. 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 12.2.15.78 PG_TYPE of the column type.

attstorage

"char"

Copy of typstorage in 12.2.15.78 PG_TYPE of the column type.

attalign

"char"

Copy of typalign in 12.2.15.78 PG_TYPE of the column type.

attnotnull

Boolean

A NOT 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 12.2.15.25 PG_ATTRDEF 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:
  • 0: not compressed (ATT_CMPR_NOCOMPRESS)
  • 1: DELTA compression algorithm (ATT_CMPR_DELTA)
  • 2: dictionary compression algorithm (ATT_CMPR_DICTIONARY)
  • 3: prefix compression algorithm (ATT_CMPR_PREFIX)
  • 4: digital string compression algorithm (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

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: default value (ATT_KV_UNDEFINED).

1: dimension (ATT_KV_TAG).

2: indicator (ATT_KV_FIELD).

3: time column (ATT_KV_TIMETAG).

4: hidden distribution key (ATT_KV_HIDETAG).

attidentity

"char"

Identity type of a column. Value:

'0' or '\0': The column is a non-IDENTITY column.

'a': The IDENTITY column attribute is of the ALWAYS type.

'd': The IDENTITY column attribute is of the BY DEFAULT type.

'n': The IDENTITY column attribute is of the BY DEFAULT ON NULL type.