<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!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><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.7. <code xmlns="http://www.w3.org/1999/xhtml" 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 11.4 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></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></h2></div></div></div><a id="id-1.10.4.9.2" class="indexterm"></a><p> The catalog <code class="structname">pg_attribute</code> stores information about table columns. There will be exactly one <code class="structname">pg_attribute</code> row for every column in every table in the database. (There will also be attribute entries for indexes, and indeed all objects that have <code class="structname">pg_class</code> entries.) </p><p> The term attribute is equivalent to column and is used for historical reasons. </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 /><col /><col /><col /></colgroup><thead><tr><th>Name</th><th>Type</th><th>References</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">attrelid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.oid</code></td><td>The table this column belongs to</td></tr><tr><td><code class="structfield">attname</code></td><td><code class="type">name</code></td><td> </td><td>The column name</td></tr><tr><td><code class="structfield">atttypid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-type.html" title="52.62. pg_type"><code class="structname">pg_type</code></a>.oid</code></td><td>The data type of this column</td></tr><tr><td><code class="structfield">attstattarget</code></td><td><code class="type">int4</code></td><td> </td><td> <code class="structfield">attstattarget</code> controls the level of detail of statistics accumulated for this column by <a class="xref" href="sql-analyze.html" title="ANALYZE"><span class="refentrytitle">ANALYZE</span></a>. 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, <code class="structfield">attstattarget</code> is both the target number of <span class="quote">“<span class="quote">most common values</span>”</span> to collect, and the target number of histogram bins to create. </td></tr><tr><td><code class="structfield">attlen</code></td><td><code class="type">int2</code></td><td> </td><td> A copy of <code class="literal">pg_type.typlen</code> of this column's type </td></tr><tr><td><code class="structfield">attnum</code></td><td><code class="type">int2</code></td><td> </td><td> The number of the column. Ordinary columns are numbered from 1 up. System columns, such as <code class="structfield">oid</code>, have (arbitrary) negative numbers. </td></tr><tr><td><code class="structfield">attndims</code></td><td><code class="type">int4</code></td><td> </td><td> 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 <span class="quote">“<span class="quote">it's an array</span>”</span>.) </td></tr><tr><td><code class="structfield">attcacheoff</code></td><td><code class="type">int4</code></td><td> </td><td> 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 </td></tr><tr><td><code class="structfield">atttypmod</code></td><td><code class="type">int4</code></td><td> </td><td> <code class="structfield">atttypmod</code> records type-specific data supplied at table creation time (for example, the maximum length of a <code class="type">varchar</code> 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 <code class="structfield">atttypmod</code>. </td></tr><tr><td><code class="structfield">attbyval</code></td><td><code class="type">bool</code></td><td> </td><td> A copy of <code class="literal">pg_type.typbyval</code> of this column's type </td></tr><tr><td><code class="structfield">attstorage</code></td><td><code class="type">char</code></td><td> </td><td> Normally a copy of <code class="literal">pg_type.typstorage</code> of this column's type. For TOAST-able data types, this can be altered after column creation to control storage policy. </td></tr><tr><td><code class="structfield">attalign</code></td><td><code class="type">char</code></td><td> </td><td> A copy of <code class="literal">pg_type.typalign</code> of this column's type </td></tr><tr><td><code class="structfield">attnotnull</code></td><td><code class="type">bool</code></td><td> </td><td> This represents a not-null constraint. </td></tr><tr><td><code class="structfield">atthasdef</code></td><td><code class="type">bool</code></td><td> </td><td> This column has a default value, in which case there will be a corresponding entry in the <code class="structname">pg_attrdef</code> catalog that actually defines the value. </td></tr><tr><td><code class="structfield">atthasmissing</code></td><td><code class="type">bool</code></td><td> </td><td> This column has a value which is used where the column is entirely missing from the row, as happens when a column is added with a non-volatile <code class="literal">DEFAULT</code> value after the row is created. The actual value used is stored in the <code class="structfield">attmissingval</code> column. </td></tr><tr><td><code class="structfield">attidentity</code></td><td><code class="type">char</code></td><td> </td><td> If a zero byte (<code class="literal">''</code>), then not an identity column. Otherwise, <code class="literal">a</code> = generated always, <code class="literal">d</code> = generated by default. </td></tr><tr><td><code class="structfield">attisdropped</code></td><td><code class="type">bool</code></td><td> </td><td> 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. </td></tr><tr><td><code class="structfield">attislocal</code></td><td><code class="type">bool</code></td><td> </td><td> This column is defined locally in the relation. Note that a column can be locally defined and inherited simultaneously. </td></tr><tr><td><code class="structfield">attinhcount</code></td><td><code class="type">int4</code></td><td> </td><td> The number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed. </td></tr><tr><td><code class="structfield">attcollation</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-collation.html" title="52.12. pg_collation"><code class="structname">pg_collation</code></a>.oid</code></td><td> The defined collation of the column, or zero if the column is not of a collatable data type. </td></tr><tr><td><code class="structfield">attacl</code></td><td><code class="type">aclitem[]</code></td><td> </td><td> Column-level access privileges, if any have been granted specifically on this column </td></tr><tr><td><code class="structfield">attoptions</code></td><td><code class="type">text[]</code></td><td> </td><td> Attribute-level options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings </td></tr><tr><td><code class="structfield">attfdwoptions</code></td><td><code class="type">text[]</code></td><td> </td><td> Attribute-level foreign data wrapper options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings </td></tr><tr><td><code class="structfield">attmissingval</code></td><td><code class="type">anyarray</code></td><td> </td><td> This column has a one element array containing the value used when the column is entirely missing from the row, as happens when the column is added with a non-volatile <code class="literal">DEFAULT</code> value after the row is created. The value is only used when <code class="structfield">atthasmissing</code> is true. If there is no value the column is null. </td></tr></tbody></table></div></div><br class="table-break" /><p> In a dropped column's <code class="structname">pg_attribute</code> entry, <code class="structfield">atttypid</code> is reset to zero, but <code class="structfield">attlen</code> and the other fields copied from <code class="structname">pg_type</code> are still valid. This arrangement is needed to cope with the situation where the dropped column's data type was later dropped, and so there is no <code class="structname">pg_type</code> row anymore. <code class="structfield">attlen</code> and the other fields can be used to interpret the contents of a row of the table. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-authid.html">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">Home</a></td><td width="40%" align="right" valign="top"> 52.8. <code class="structname">pg_authid</code></td></tr></table></div></body></html>