codekingpro/portable-devtools
115k
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>53.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="53.6. pg_attrdef" /><link rel="next" href="catalog-pg-authid.html" title="53.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">53.7. <code class="structname">pg_attribute</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-attrdef.html" title="53.6. pg_attrdef">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 53. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-authid.html" title="53.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">53.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 about4 table columns. There will be exactly one5 <code class="structname">pg_attribute</code> row for every column in every6 table in the database. (There will also be attribute entries for7 indexes, and indeed all objects that have8 <a class="link" href="catalog-pg-class.html" title="53.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 for12 historical reasons.13 </p><div class="table" id="id-1.10.4.9.5"><p class="title"><strong>Table 53.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 Type15 </p>16 <p>17 Description18 </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="53.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 to24 </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 name29 </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="53.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's40 type41 </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 146 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">attcacheoff</code> <code class="type">int4</code>50 </p>51 <p>52 Always -1 in storage, but when loaded into a row descriptor53 in memory this might be updated to cache the offset of the attribute54 within the row55 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">56 <code class="structfield">atttypmod</code> <code class="type">int4</code>57 </p>58 <p>59 <code class="structfield">atttypmod</code> records type-specific data60 supplied at table creation time (for example, the maximum61 length of a <code class="type">varchar</code> column). It is passed to62 type-specific input functions and length coercion functions.63 The value will generally be -1 for types that do not need <code class="structfield">atttypmod</code>.64 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">65 <code class="structfield">attndims</code> <code class="type">int2</code>66 </p>67 <p>68 Number of dimensions, if the column is an array type; otherwise 0.69 (Presently, the number of dimensions of an array is not enforced,70 so any nonzero value effectively means <span class="quote">“<span class="quote">it's an array</span>”</span>.)71 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">72 <code class="structfield">attbyval</code> <code class="type">bool</code>73 </p>74 <p>75 A copy of <code class="literal">pg_type.typbyval</code> of this column's type76 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">77 <code class="structfield">attalign</code> <code class="type">char</code>78 </p>79 <p>80 A copy of <code class="literal">pg_type.typalign</code> of this column's type81 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">82 <code class="structfield">attstorage</code> <code class="type">char</code>83 </p>84 <p>85 Normally a copy of <code class="literal">pg_type.typstorage</code> of this86 column's type. For TOAST-able data types, this can be altered87 after column creation to control storage policy.88 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">89 <code class="structfield">attcompression</code> <code class="type">char</code>90 </p>91 <p>92 The current compression method of the column. Typically this is93 <code class="literal">'\0'</code> to specify use of the current default setting94 (see <a class="xref" href="runtime-config-client.html#GUC-DEFAULT-TOAST-COMPRESSION">default_toast_compression</a>). Otherwise,95 <code class="literal">'p'</code> selects pglz compression, while96 <code class="literal">'l'</code> selects <span class="productname">LZ4</span>97 compression. However, this field is ignored98 whenever <code class="structfield">attstorage</code> does not allow99 compression.100 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">101 <code class="structfield">attnotnull</code> <code class="type">bool</code>102 </p>103 <p>104 This represents a not-null constraint.105 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">106 <code class="structfield">atthasdef</code> <code class="type">bool</code>107 </p>108 <p>109 This column has a default expression or generation expression, in which110 case there will be a corresponding entry in the111 <a class="link" href="catalog-pg-attrdef.html" title="53.6. pg_attrdef"><code class="structname">pg_attrdef</code></a> catalog that actually defines the112 expression. (Check <code class="structfield">attgenerated</code> to113 determine whether this is a default or a generation expression.)114 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">115 <code class="structfield">atthasmissing</code> <code class="type">bool</code>116 </p>117 <p>118 This column has a value which is used where the column is entirely119 missing from the row, as happens when a column is added with a120 non-volatile <code class="literal">DEFAULT</code> value after the row is created.121 The actual value used is stored in the122 <code class="structfield">attmissingval</code> column.123 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">124 <code class="structfield">attidentity</code> <code class="type">char</code>125 </p>126 <p>127 If a zero byte (<code class="literal">''</code>), then not an identity column.128 Otherwise, <code class="literal">a</code> = generated129 always, <code class="literal">d</code> = generated by default.130 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">131 <code class="structfield">attgenerated</code> <code class="type">char</code>132 </p>133 <p>134 If a zero byte (<code class="literal">''</code>), then not a generated column.135 Otherwise, <code class="literal">s</code> = stored. (Other values might be added136 in the future.)137 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">138 <code class="structfield">attisdropped</code> <code class="type">bool</code>139 </p>140 <p>141 This column has been dropped and is no longer valid. A dropped142 column is still physically present in the table, but is143 ignored by the parser and so cannot be accessed via SQL.144 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">145 <code class="structfield">attislocal</code> <code class="type">bool</code>146 </p>147 <p>148 This column is defined locally in the relation. Note that a column can149 be locally defined and inherited simultaneously.150 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">151 <code class="structfield">attinhcount</code> <code class="type">int2</code>152 </p>153 <p>154 The number of direct ancestors this column has. A column with a155 nonzero number of ancestors cannot be dropped nor renamed.156 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">157 <code class="structfield">attstattarget</code> <code class="type">int2</code>158 </p>159 <p>160 <code class="structfield">attstattarget</code> controls the level of detail161 of statistics accumulated for this column by162 <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>.163 A zero value indicates that no statistics should be collected.164 A negative value says to use the system default statistics target.165 The exact meaning of positive values is data type-dependent.166 For scalar data types, <code class="structfield">attstattarget</code>167 is both the target number of <span class="quote">“<span class="quote">most common values</span>”</span>168 to collect, and the target number of histogram bins to create.169 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">170 <code class="structfield">attcollation</code> <code class="type">oid</code>171 (references <a class="link" href="catalog-pg-collation.html" title="53.12. pg_collation"><code class="structname">pg_collation</code></a>.<code class="structfield">oid</code>)172 </p>173 <p>174 The defined collation of the column, or zero if the column is175 not of a collatable data type176 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">177 <code class="structfield">attacl</code> <code class="type">aclitem[]</code>178 </p>179 <p>180 Column-level access privileges, if any have been granted specifically181 on this column182 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">183 <code class="structfield">attoptions</code> <code class="type">text[]</code>184 </p>185 <p>186 Attribute-level options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings187 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">188 <code class="structfield">attfdwoptions</code> <code class="type">text[]</code>189 </p>190 <p>191 Attribute-level foreign data wrapper options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings192 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">193 <code class="structfield">attmissingval</code> <code class="type">anyarray</code>194 </p>195 <p>196 This column has a one element array containing the value used when the197 column is entirely missing from the row, as happens when the column is198 added with a non-volatile <code class="literal">DEFAULT</code> value after the199 row is created. The value is only used when200 <code class="structfield">atthasmissing</code> is true. If there is no value201 the column is null.202 </p></td></tr></tbody></table></div></div><br class="table-break" /><p>203 In a dropped column's <code class="structname">pg_attribute</code> entry,204 <code class="structfield">atttypid</code> is reset to zero, but205 <code class="structfield">attlen</code> and the other fields copied from206 <a class="link" href="catalog-pg-type.html" title="53.64. pg_type"><code class="structname">pg_type</code></a> are still valid. This arrangement is needed207 to cope with the situation where the dropped column's data type was208 later dropped, and so there is no <code class="structname">pg_type</code> row anymore.209 <code class="structfield">attlen</code> and the other fields can be used210 to interpret the contents of a row of the table.211 </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="53.6. pg_attrdef">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 53. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-authid.html" title="53.8. pg_authid">Next</a></td></tr><tr><td width="40%" align="left" valign="top">53.6. <code class="structname">pg_attrdef</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 53.8. <code class="structname">pg_authid</code></td></tr></table></div></body></html>