]> begriffs open source - ai-pg/blob - full-docs/txt/catalog-pg-attribute.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / catalog-pg-attribute.txt
1
2 52.7. pg_attribute #
3
4    The catalog pg_attribute stores information about table columns. There
5    will be exactly one pg_attribute row for every column in every table in
6    the database. (There will also be attribute entries for indexes, and
7    indeed all objects that have pg_class entries.)
8
9    The term attribute is equivalent to column and is used for historical
10    reasons.
11
12    Table 52.7. pg_attribute Columns
13
14    Column Type
15
16    Description
17
18    attrelid oid (references pg_class.oid)
19
20    The table this column belongs to
21
22    attname name
23
24    The column name
25
26    atttypid oid (references pg_type.oid)
27
28    The data type of this column (zero for a dropped column)
29
30    attlen int2
31
32    A copy of pg_type.typlen of this column's type
33
34    attnum int2
35
36    The number of the column. Ordinary columns are numbered from 1 up.
37    System columns, such as ctid, have (arbitrary) negative numbers.
38
39    atttypmod int4
40
41    atttypmod records type-specific data supplied at table creation time
42    (for example, the maximum length of a varchar column). It is passed to
43    type-specific input functions and length coercion functions. The value
44    will generally be -1 for types that do not need atttypmod.
45
46    attndims int2
47
48    Number of dimensions, if the column is an array type; otherwise 0.
49    (Presently, the number of dimensions of an array is not enforced, so
50    any nonzero value effectively means “it's an array”.)
51
52    attbyval bool
53
54    A copy of pg_type.typbyval of this column's type
55
56    attalign char
57
58    A copy of pg_type.typalign of this column's type
59
60    attstorage char
61
62    Normally a copy of pg_type.typstorage of this column's type. For
63    TOAST-able data types, this can be altered after column creation to
64    control storage policy.
65
66    attcompression char
67
68    The current compression method of the column. Typically this is '\0' to
69    specify use of the current default setting (see
70    default_toast_compression). Otherwise, 'p' selects pglz compression,
71    while 'l' selects LZ4 compression. However, this field is ignored
72    whenever attstorage does not allow compression.
73
74    attnotnull bool
75
76    This column has a (possibly invalid) not-null constraint.
77
78    atthasdef bool
79
80    This column has a default expression or generation expression, in which
81    case there will be a corresponding entry in the pg_attrdef catalog that
82    actually defines the expression. (Check attgenerated to determine
83    whether this is a default or a generation expression.)
84
85    atthasmissing bool
86
87    This column has a value which is used where the column is entirely
88    missing from the row, as happens when a column is added with a
89    non-volatile DEFAULT value after the row is created. The actual value
90    used is stored in the attmissingval column.
91
92    attidentity char
93
94    If a zero byte (''), then not an identity column. Otherwise, a =
95    generated always, d = generated by default.
96
97    attgenerated char
98
99    If a zero byte (''), then not a generated column. Otherwise, s =
100    stored, v = virtual. A stored generated column is physically stored
101    like a normal column. A virtual generated column is physically stored
102    as a null value, with the actual value being computed at run time.
103
104    attisdropped bool
105
106    This column has been dropped and is no longer valid. A dropped column
107    is still physically present in the table, but is ignored by the parser
108    and so cannot be accessed via SQL.
109
110    attislocal bool
111
112    This column is defined locally in the relation. Note that a column can
113    be locally defined and inherited simultaneously.
114
115    attinhcount int2
116
117    The number of direct ancestors this column has. A column with a nonzero
118    number of ancestors cannot be dropped nor renamed.
119
120    attcollation oid (references pg_collation.oid)
121
122    The defined collation of the column, or zero if the column is not of a
123    collatable data type
124
125    attstattarget int2
126
127    attstattarget controls the level of detail of statistics accumulated
128    for this column by ANALYZE. A zero value indicates that no statistics
129    should be collected. A null value says to use the system default
130    statistics target. The exact meaning of positive values is data
131    type-dependent. For scalar data types, attstattarget is both the target
132    number of “most common values” to collect, and the target number of
133    histogram bins to create.
134
135    attacl aclitem[]
136
137    Column-level access privileges, if any have been granted specifically
138    on this column
139
140    attoptions text[]
141
142    Attribute-level options, as “keyword=value” strings
143
144    attfdwoptions text[]
145
146    Attribute-level foreign data wrapper options, as “keyword=value”
147    strings
148
149    attmissingval anyarray
150
151    This column has a one element array containing the value used when the
152    column is entirely missing from the row, as happens when the column is
153    added with a non-volatile DEFAULT value after the row is created. The
154    value is only used when atthasmissing is true. If there is no value the
155    column is null.
156
157    In a dropped column's pg_attribute entry, atttypid is reset to zero,
158    but attlen and the other fields copied from pg_type are still valid.
159    This arrangement is needed to cope with the situation where the dropped
160    column's data type was later dropped, and so there is no pg_type row
161    anymore. attlen and the other fields can be used to interpret the
162    contents of a row of the table.