pg_attribute

3.7. pg_attribute

pg_attribute 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 other objects. See pg_class.)

The term attribute is equivalent to column and is used for historical reasons.

Table 3-7. pg_attribute Columns

NameTypeReferencesDescription
attrelidoidpg_class.oidThe table this column belongs to
attnamename 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 datatype-dependent. For scalar datatypes, attstattarget is both the target number of "most common values" to collect, and the target number of histogram bins to create.
attlenint2  This is 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 tuple descriptor in memory this may be updated to cache the offset of the attribute within the tuple.
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 typmod.
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 TOASTable datatypes, this can be altered after column creation to control storage policy.
attissetbool  If true, this attribute is a set. In that case, what is really stored in the attribute is the OID of a tuple in the pg_proc catalog. The pg_proc tuple contains the query string that defines this set - i.e., the query to run to get the set. So the atttypid (see above) refers to the type returned by this query, but the actual length of this attribute is the length (size) of an oid. --- At least this is the theory. All this is probably quite broken these days.
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 field 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 may 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.
© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.