↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

支持中的版本: 当前版本 (18) / 17 / 16 / 15 / 14
开发中的版本: 19 / 20devel
已结束支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
历史版本。 PostgreSQL 9.1 已结束支持。 2016-10-27. 请参阅 当前版本手册.

45.7. pg_attribute #

目录pg_attribute存储关于表列的信息。数据库中每个表的每一列,在pg_attribute中都恰好有一行。(其中也包括索引的属性项,实际上,凡是在pg_class中有项的对象,都有对应的属性项。)

术语属性等同于列,这里使用它只是出于历史原因。

表 45.7. pg_attribute 列

NameTypeReferencesDescription
attrelidoidpg_class.oidThe table this column belongs to
attnamename The column name
atttypidoidpg_type.oidThe data type of this column
attstattargetint4  attstattarget controls the level of detail of statistics accumulated for this column by ANALYZE. A zero value indicates that no statistics should be collected. A negative 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.
attlenint2  A copy of pg_type.typlen of this column's type
attnumint2  The number of the column. Ordinary columns are numbered from 1 up. System columns, such as oid, have (arbitrary) negative numbers.
attndimsint4  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's an array”.)
attcacheoffint4  Always -1 in storage, but when loaded into a row descriptor in memory this might be updated to cache the offset of the attribute within the row
atttypmodint4  atttypmod 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.
attbyvalbool  A copy of pg_type.typbyval of this column's type
attstoragechar  Normally 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.
attalignchar  A copy of pg_type.typalign of this column's type
attnotnullbool  This represents a not-null constraint. It is possible to change this column to enable or disable the constraint.
atthasdefbool  This column has a default value, in which case there will be a corresponding entry in the pg_attrdef catalog that actually defines the value.
attisdroppedbool  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.
attislocalbool  This column is defined locally in the relation. Note that a column can be locally defined and inherited simultaneously.
attinhcountint4  The number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed.
attcollationoidpg_collation.oid The defined collation of the column, or zero if the column is not of a collatable data type.
attaclaclitem[]  Column-level access privileges, if any have been granted specifically on this column
attoptionstext[]  Attribute-level options, as “keyword=value” strings

在被删除列的 pg_attribute 条目中,atttypid 被重置为零,但 attlen 以及其他从 pg_type 复制的字段仍然有效。这种安排用于应对被删除列的数据类型后来也被删除、因而不再有相应 pg_type 行的情况。attlen 和其他字段可用于解释表中一行的内容。

报告文档问题

阅读 上游文档. 反馈更正前请先核对 当前版本手册.