]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/catalog-pg-attribute.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / catalog-pg-attribute.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>52.7. pg_attribute</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="catalog-pg-attrdef.html" title="52.6. pg_attrdef" /><link rel="next" href="catalog-pg-authid.html" title="52.8. pg_authid" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.7. <code class="structname">pg_attribute</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-attrdef.html" title="52.6. pg_attrdef">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 52. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 52. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-authid.html" title="52.8. pg_authid">Next</a></td></tr></table><hr /></div><div class="sect1" id="CATALOG-PG-ATTRIBUTE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.7. <code class="structname">pg_attribute</code> <a href="#CATALOG-PG-ATTRIBUTE" class="id_link">#</a></h2></div></div></div><a id="id-1.10.4.9.2" class="indexterm"></a><p>
3    The catalog <code class="structname">pg_attribute</code> stores information about
4    table columns.  There will be exactly one
5    <code class="structname">pg_attribute</code> row for every column in every
6    table in the database.  (There will also be attribute entries for
7    indexes, and indeed all objects that have
8    <a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>
9    entries.)
10   </p><p>
11    The term attribute is equivalent to column and is used for
12    historical reasons.
13   </p><div class="table" id="id-1.10.4.9.5"><p class="title"><strong>Table 52.7. <code class="structname">pg_attribute</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_attribute Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">
14        Column Type
15       </p>
16       <p>
17        Description
18       </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
19        <code class="structfield">attrelid</code> <code class="type">oid</code>
20        (references <a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>)
21       </p>
22       <p>
23        The table this column belongs to
24       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
25        <code class="structfield">attname</code> <code class="type">name</code>
26       </p>
27       <p>
28        The column name
29       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
30        <code class="structfield">atttypid</code> <code class="type">oid</code>
31        (references <a class="link" href="catalog-pg-type.html" title="52.64. pg_type"><code class="structname">pg_type</code></a>.<code class="structfield">oid</code>)
32       </p>
33       <p>
34        The data type of this column (zero for a dropped column)
35       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
36        <code class="structfield">attlen</code> <code class="type">int2</code>
37       </p>
38       <p>
39        A copy of <code class="literal">pg_type.typlen</code> of this column's
40        type
41       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
42        <code class="structfield">attnum</code> <code class="type">int2</code>
43       </p>
44       <p>
45        The number of the column.  Ordinary columns are numbered from 1
46        up.  System columns, such as <code class="structfield">ctid</code>,
47        have (arbitrary) negative numbers.
48       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
49        <code class="structfield">atttypmod</code> <code class="type">int4</code>
50       </p>
51       <p>
52        <code class="structfield">atttypmod</code> records type-specific data
53        supplied at table creation time (for example, the maximum
54        length of a <code class="type">varchar</code> column).  It is passed to
55        type-specific input functions and length coercion functions.
56        The value will generally be -1 for types that do not need <code class="structfield">atttypmod</code>.
57       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
58        <code class="structfield">attndims</code> <code class="type">int2</code>
59       </p>
60       <p>
61        Number of dimensions, if the column is an array type; otherwise 0.
62        (Presently, the number of dimensions of an array is not enforced,
63        so any nonzero value effectively means <span class="quote">“<span class="quote">it's an array</span>”</span>.)
64       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
65        <code class="structfield">attbyval</code> <code class="type">bool</code>
66       </p>
67       <p>
68        A copy of <code class="literal">pg_type.typbyval</code> of this column's type
69       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
70        <code class="structfield">attalign</code> <code class="type">char</code>
71       </p>
72       <p>
73        A copy of <code class="literal">pg_type.typalign</code> of this column's type
74       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
75        <code class="structfield">attstorage</code> <code class="type">char</code>
76       </p>
77       <p>
78        Normally a copy of <code class="literal">pg_type.typstorage</code> of this
79        column's type.  For TOAST-able data types, this can be altered
80        after column creation to control storage policy.
81       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
82        <code class="structfield">attcompression</code> <code class="type">char</code>
83       </p>
84       <p>
85        The current compression method of the column.  Typically this is
86        <code class="literal">'\0'</code> to specify use of the current default setting
87        (see <a class="xref" href="runtime-config-client.html#GUC-DEFAULT-TOAST-COMPRESSION">default_toast_compression</a>).  Otherwise,
88        <code class="literal">'p'</code> selects pglz compression, while
89        <code class="literal">'l'</code> selects <span class="productname">LZ4</span>
90        compression.  However, this field is ignored
91        whenever <code class="structfield">attstorage</code> does not allow
92        compression.
93       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
94        <code class="structfield">attnotnull</code> <code class="type">bool</code>
95       </p>
96       <p>
97        This column has a (possibly invalid) not-null constraint.
98       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
99        <code class="structfield">atthasdef</code> <code class="type">bool</code>
100       </p>
101       <p>
102        This column has a default expression or generation expression, in which
103        case there will be a corresponding entry in the
104        <a class="link" href="catalog-pg-attrdef.html" title="52.6. pg_attrdef"><code class="structname">pg_attrdef</code></a> catalog that actually defines the
105        expression.  (Check <code class="structfield">attgenerated</code> to
106        determine whether this is a default or a generation expression.)
107       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
108        <code class="structfield">atthasmissing</code> <code class="type">bool</code>
109       </p>
110       <p>
111        This column has a value which is used where the column is entirely
112        missing from the row, as happens when a column is added with a
113        non-volatile <code class="literal">DEFAULT</code> value after the row is created.
114        The actual value used is stored in the
115        <code class="structfield">attmissingval</code> column.
116       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
117        <code class="structfield">attidentity</code> <code class="type">char</code>
118       </p>
119       <p>
120        If a zero byte (<code class="literal">''</code>), then not an identity column.
121        Otherwise, <code class="literal">a</code> = generated
122        always, <code class="literal">d</code> = generated by default.
123       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
124        <code class="structfield">attgenerated</code> <code class="type">char</code>
125       </p>
126       <p>
127        If a zero byte (<code class="literal">''</code>), then not a generated column.
128        Otherwise, <code class="literal">s</code> = stored, <code class="literal">v</code> =
129        virtual.  A stored generated column is physically stored like a normal
130        column.  A virtual generated column is physically stored as a null
131        value, with the actual value being computed at run time.
132       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
133        <code class="structfield">attisdropped</code> <code class="type">bool</code>
134       </p>
135       <p>
136        This column has been dropped and is no longer valid.  A dropped
137        column is still physically present in the table, but is
138        ignored by the parser and so cannot be accessed via SQL.
139       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
140        <code class="structfield">attislocal</code> <code class="type">bool</code>
141       </p>
142       <p>
143        This column is defined locally in the relation.  Note that a column can
144        be locally defined and inherited simultaneously.
145       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
146        <code class="structfield">attinhcount</code> <code class="type">int2</code>
147       </p>
148       <p>
149        The number of direct ancestors this column has.  A column with a
150        nonzero number of ancestors cannot be dropped nor renamed.
151       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
152        <code class="structfield">attcollation</code> <code class="type">oid</code>
153        (references <a class="link" href="catalog-pg-collation.html" title="52.12. pg_collation"><code class="structname">pg_collation</code></a>.<code class="structfield">oid</code>)
154       </p>
155       <p>
156        The defined collation of the column, or zero if the column is
157        not of a collatable data type
158       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
159        <code class="structfield">attstattarget</code> <code class="type">int2</code>
160       </p>
161       <p>
162        <code class="structfield">attstattarget</code> controls the level of detail
163        of statistics accumulated for this column by
164        <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>.
165        A zero value indicates that no statistics should be collected.
166        A null value says to use the system default statistics target.
167        The exact meaning of positive values is data type-dependent.
168        For scalar data types, <code class="structfield">attstattarget</code>
169        is both the target number of <span class="quote">“<span class="quote">most common values</span>”</span>
170        to collect, and the target number of histogram bins to create.
171       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
172        <code class="structfield">attacl</code> <code class="type">aclitem[]</code>
173       </p>
174       <p>
175        Column-level access privileges, if any have been granted specifically
176        on this column
177       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
178        <code class="structfield">attoptions</code> <code class="type">text[]</code>
179       </p>
180       <p>
181        Attribute-level options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings
182       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
183        <code class="structfield">attfdwoptions</code> <code class="type">text[]</code>
184       </p>
185       <p>
186        Attribute-level foreign data wrapper options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings
187       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
188        <code class="structfield">attmissingval</code> <code class="type">anyarray</code>
189       </p>
190       <p>
191        This column has a one element array containing the value used when the
192        column is entirely missing from the row, as happens when the column is
193        added with a non-volatile <code class="literal">DEFAULT</code> value after the
194        row is created.  The value is only used when
195        <code class="structfield">atthasmissing</code> is true.  If there is no value
196        the column is null.
197       </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
198    In a dropped column's <code class="structname">pg_attribute</code> entry,
199    <code class="structfield">atttypid</code> is reset to zero, but
200    <code class="structfield">attlen</code> and the other fields copied from
201    <a class="link" href="catalog-pg-type.html" title="52.64. pg_type"><code class="structname">pg_type</code></a> are still valid.  This arrangement is needed
202    to cope with the situation where the dropped column's data type was
203    later dropped, and so there is no <code class="structname">pg_type</code> row anymore.
204    <code class="structfield">attlen</code> and the other fields can be used
205    to interpret the contents of a row of the table.
206   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-attrdef.html" title="52.6. pg_attrdef">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 52. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-authid.html" title="52.8. pg_authid">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.6. <code class="structname">pg_attrdef</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 52.8. <code class="structname">pg_authid</code></td></tr></table></div></body></html>