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.11. pg_class</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-cast.html" title="53.10. pg_cast" /><link rel="next" href="catalog-pg-collation.html" title="53.12. pg_collation" /></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.11. <code class="structname">pg_class</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-cast.html" title="53.10. pg_cast">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-collation.html" title="53.12. pg_collation">Next</a></td></tr></table><hr /></div><div class="sect1" id="CATALOG-PG-CLASS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">53.11. <code class="structname">pg_class</code> <a href="#CATALOG-PG-CLASS" class="id_link">#</a></h2></div></div></div><a id="id-1.10.4.13.2" class="indexterm"></a><p>3 The catalog <code class="structname">pg_class</code> describes tables and4 other objects that have columns or are otherwise similar to a5 table. This includes indexes (but see also <a class="link" href="catalog-pg-index.html" title="53.26. pg_index"><code class="structname">pg_index</code></a>),6 sequences (but see also <a class="link" href="catalog-pg-sequence.html" title="53.47. pg_sequence"><code class="structname">pg_sequence</code></a>),7 views, materialized views, composite types, and TOAST tables;8 see <code class="structfield">relkind</code>.9 Below, when we mean all of these kinds of objects we speak of10 <span class="quote">“<span class="quote">relations</span>”</span>. Not all of <code class="structname">pg_class</code>'s11 columns are meaningful for all relation kinds.12 </p><div class="table" id="id-1.10.4.13.4"><p class="title"><strong>Table 53.11. <code class="structname">pg_class</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_class Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">13 Column Type14 </p>15 <p>16 Description17 </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">18 <code class="structfield">oid</code> <code class="type">oid</code>19 </p>20 <p>21 Row identifier22 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">23 <code class="structfield">relname</code> <code class="type">name</code>24 </p>25 <p>26 Name of the table, index, view, etc.27 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">28 <code class="structfield">relnamespace</code> <code class="type">oid</code>29 (references <a class="link" href="catalog-pg-namespace.html" title="53.32. pg_namespace"><code class="structname">pg_namespace</code></a>.<code class="structfield">oid</code>)30 </p>31 <p>32 The OID of the namespace that contains this relation33 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">34 <code class="structfield">reltype</code> <code class="type">oid</code>35 (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>)36 </p>37 <p>38 The OID of the data type that corresponds to this table's row type,39 if any; zero for indexes, sequences, and toast tables, which have40 no <code class="structname">pg_type</code> entry41 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">42 <code class="structfield">reloftype</code> <code class="type">oid</code>43 (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>)44 </p>45 <p>46 For typed tables, the OID of the underlying composite type;47 zero for all other relations48 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">49 <code class="structfield">relowner</code> <code class="type">oid</code>50 (references <a class="link" href="catalog-pg-authid.html" title="53.8. pg_authid"><code class="structname">pg_authid</code></a>.<code class="structfield">oid</code>)51 </p>52 <p>53 Owner of the relation54 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">55 <code class="structfield">relam</code> <code class="type">oid</code>56 (references <a class="link" href="catalog-pg-am.html" title="53.3. pg_am"><code class="structname">pg_am</code></a>.<code class="structfield">oid</code>)57 </p>58 <p>59 If this is a table or an index, the access method used (heap,60 B-tree, hash, etc.); otherwise zero (zero occurs for sequences,61 as well as relations without storage, such as views)62 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">63 <code class="structfield">relfilenode</code> <code class="type">oid</code>64 </p>65 <p>66 Name of the on-disk file of this relation; zero means this67 is a <span class="quote">“<span class="quote">mapped</span>”</span> relation whose disk file name is determined68 by low-level state69 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">70 <code class="structfield">reltablespace</code> <code class="type">oid</code>71 (references <a class="link" href="catalog-pg-tablespace.html" title="53.56. pg_tablespace"><code class="structname">pg_tablespace</code></a>.<code class="structfield">oid</code>)72 </p>73 <p>74 The tablespace in which this relation is stored.75 If zero, the database's default tablespace is implied.76 Not meaningful if the relation has no on-disk file,77 except for partitioned tables, where this is the tablespace78 in which partitions will be created when one is not79 specified in the creation command.80 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">81 <code class="structfield">relpages</code> <code class="type">int4</code>82 </p>83 <p>84 Size of the on-disk representation of this table in pages (of size85 <code class="symbol">BLCKSZ</code>). This is only an estimate used by the86 planner. It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,87 <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as88 <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.89 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">90 <code class="structfield">reltuples</code> <code class="type">float4</code>91 </p>92 <p>93 Number of live rows in the table. This is only an estimate used by94 the planner. It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,95 <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as96 <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.97 If the table has never yet been vacuumed or98 analyzed, <code class="structfield">reltuples</code>99 contains <code class="literal">-1</code> indicating that the row count is100 unknown.101 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">102 <code class="structfield">relallvisible</code> <code class="type">int4</code>103 </p>104 <p>105 Number of pages that are marked all-visible in the table's106 visibility map. This is only an estimate used by the107 planner. It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,108 <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as109 <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.110 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">111 <code class="structfield">reltoastrelid</code> <code class="type">oid</code>112 (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>)113 </p>114 <p>115 OID of the TOAST table associated with this table, zero if none. The116 TOAST table stores large attributes <span class="quote">“<span class="quote">out of line</span>”</span> in a117 secondary table.118 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">119 <code class="structfield">relhasindex</code> <code class="type">bool</code>120 </p>121 <p>122 True if this is a table and it has (or recently had) any indexes123 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">124 <code class="structfield">relisshared</code> <code class="type">bool</code>125 </p>126 <p>127 True if this table is shared across all databases in the cluster. Only128 certain system catalogs (such as <a class="link" href="catalog-pg-database.html" title="53.15. pg_database"><code class="structname">pg_database</code></a>)129 are shared.130 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">131 <code class="structfield">relpersistence</code> <code class="type">char</code>132 </p>133 <p>134 <code class="literal">p</code> = permanent table/sequence, <code class="literal">u</code> = unlogged table/sequence,135 <code class="literal">t</code> = temporary table/sequence136 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">137 <code class="structfield">relkind</code> <code class="type">char</code>138 </p>139 <p>140 <code class="literal">r</code> = ordinary table,141 <code class="literal">i</code> = index,142 <code class="literal">S</code> = sequence,143 <code class="literal">t</code> = TOAST table,144 <code class="literal">v</code> = view,145 <code class="literal">m</code> = materialized view,146 <code class="literal">c</code> = composite type,147 <code class="literal">f</code> = foreign table,148 <code class="literal">p</code> = partitioned table,149 <code class="literal">I</code> = partitioned index150 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">151 <code class="structfield">relnatts</code> <code class="type">int2</code>152 </p>153 <p>154 Number of user columns in the relation (system columns not155 counted). There must be this many corresponding entries in156 <a class="link" href="catalog-pg-attribute.html" title="53.7. pg_attribute"><code class="structname">pg_attribute</code></a>. See also157 <code class="structname">pg_attribute</code>.<code class="structfield">attnum</code>.158 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">159 <code class="structfield">relchecks</code> <code class="type">int2</code>160 </p>161 <p>162 Number of <code class="literal">CHECK</code> constraints on the table; see163 <a class="link" href="catalog-pg-constraint.html" title="53.13. pg_constraint"><code class="structname">pg_constraint</code></a> catalog164 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">165 <code class="structfield">relhasrules</code> <code class="type">bool</code>166 </p>167 <p>168 True if table has (or once had) rules; see169 <a class="link" href="catalog-pg-rewrite.html" title="53.45. pg_rewrite"><code class="structname">pg_rewrite</code></a> catalog170 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">171 <code class="structfield">relhastriggers</code> <code class="type">bool</code>172 </p>173 <p>174 True if table has (or once had) triggers; see175 <a class="link" href="catalog-pg-trigger.html" title="53.58. pg_trigger"><code class="structname">pg_trigger</code></a> catalog176 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">177 <code class="structfield">relhassubclass</code> <code class="type">bool</code>178 </p>179 <p>180 True if table or index has (or once had) any inheritance children or partitions181 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">182 <code class="structfield">relrowsecurity</code> <code class="type">bool</code>183 </p>184 <p>185 True if table has row-level security enabled; see186 <a class="link" href="catalog-pg-policy.html" title="53.38. pg_policy"><code class="structname">pg_policy</code></a> catalog187 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">188 <code class="structfield">relforcerowsecurity</code> <code class="type">bool</code>189 </p>190 <p>191 True if row-level security (when enabled) will also apply to table owner; see192 <a class="link" href="catalog-pg-policy.html" title="53.38. pg_policy"><code class="structname">pg_policy</code></a> catalog193 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">194 <code class="structfield">relispopulated</code> <code class="type">bool</code>195 </p>196 <p>197 True if relation is populated (this is true for all198 relations other than some materialized views)199 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">200 <code class="structfield">relreplident</code> <code class="type">char</code>201 </p>202 <p>203 Columns used to form <span class="quote">“<span class="quote">replica identity</span>”</span> for rows:204 <code class="literal">d</code> = default (primary key, if any),205 <code class="literal">n</code> = nothing,206 <code class="literal">f</code> = all columns,207 <code class="literal">i</code> = index with208 <code class="structfield">indisreplident</code> set (same as nothing if the209 index used has been dropped)210 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">211 <code class="structfield">relispartition</code> <code class="type">bool</code>212 </p>213 <p>214 True if table or index is a partition215 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">216 <code class="structfield">relrewrite</code> <code class="type">oid</code>217 (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>)218 </p>219 <p>220 For new relations being written during a DDL operation that requires a221 table rewrite, this contains the OID of the original relation;222 otherwise zero. That state is only visible internally; this field should223 never contain anything other than zero for a user-visible relation.224 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">225 <code class="structfield">relfrozenxid</code> <code class="type">xid</code>226 </p>227 <p>228 All transaction IDs before this one have been replaced with a permanent229 (<span class="quote">“<span class="quote">frozen</span>”</span>) transaction ID in this table. This is used to track230 whether the table needs to be vacuumed in order to prevent transaction231 ID wraparound or to allow <code class="literal">pg_xact</code> to be shrunk. Zero232 (<code class="symbol">InvalidTransactionId</code>) if the relation is not a table.233 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">234 <code class="structfield">relminmxid</code> <code class="type">xid</code>235 </p>236 <p>237 All multixact IDs before this one have been replaced by a238 transaction ID in this table. This is used to track239 whether the table needs to be vacuumed in order to prevent multixact ID240 wraparound or to allow <code class="literal">pg_multixact</code> to be shrunk. Zero241 (<code class="symbol">InvalidMultiXactId</code>) if the relation is not a table.242 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">243 <code class="structfield">relacl</code> <code class="type">aclitem[]</code>244 </p>245 <p>246 Access privileges; see <a class="xref" href="ddl-priv.html" title="5.7. Privileges">Section 5.7</a> for details247 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">248 <code class="structfield">reloptions</code> <code class="type">text[]</code>249 </p>250 <p>251 Access-method-specific options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings252 </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">253 <code class="structfield">relpartbound</code> <code class="type">pg_node_tree</code>254 </p>255 <p>256 If table is a partition (see <code class="structfield">relispartition</code>),257 internal representation of the partition bound258 </p></td></tr></tbody></table></div></div><br class="table-break" /><p>259 Several of the Boolean flags in <code class="structname">pg_class</code> are maintained260 lazily: they are guaranteed to be true if that's the correct state, but261 may not be reset to false immediately when the condition is no longer262 true. For example, <code class="structfield">relhasindex</code> is set by263 <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>, but it is never cleared by264 <a class="link" href="sql-dropindex.html" title="DROP INDEX"><code class="command">DROP INDEX</code></a>. Instead, <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a> clears265 <code class="structfield">relhasindex</code> if it finds the table has no indexes. This266 arrangement avoids race conditions and improves concurrency.267 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-cast.html" title="53.10. pg_cast">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-collation.html" title="53.12. pg_collation">Next</a></td></tr><tr><td width="40%" align="left" valign="top">53.10. <code class="structname">pg_cast</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.12. <code class="structname">pg_collation</code></td></tr></table></div></body></html>