Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
opt
/
postgresql-13
/
doc
/
html
/
//opt/postgresql-13/doc/html/catalog-pg-class.html
<?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>51.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 V1.79.1" /><link rel="prev" href="catalog-pg-cast.html" title="51.10. pg_cast" /><link rel="next" href="catalog-pg-collation.html" title="51.12. pg_collation" /></head><body id="docContent" class="container-fluid col-10"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">51.11. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_class</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-cast.html" title="51.10. pg_cast">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 51. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 51. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 13.1 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-collation.html" title="51.12. pg_collation">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="CATALOG-PG-CLASS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">51.11. <code class="structname">pg_class</code></h2></div></div></div><a id="id-1.10.4.13.2" class="indexterm"></a><p> The catalog <code class="structname">pg_class</code> catalogs tables and most everything else that has columns or is otherwise similar to a table. This includes indexes (but see also <code class="structname">pg_index</code>), sequences (but see also <code class="structname">pg_sequence</code>), views, materialized views, composite types, and TOAST tables; see <code class="structfield">relkind</code>. Below, when we mean all of these kinds of objects we speak of <span class="quote">“<span class="quote">relations</span>”</span>. Not all columns are meaningful for all relation types. </p><div class="table" id="id-1.10.4.13.4"><p class="title"><strong>Table 51.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"> Column Type </p> <p> Description </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">oid</code> <code class="type">oid</code> </p> <p> Row identifier </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relname</code> <code class="type">name</code> </p> <p> Name of the table, index, view, etc. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relnamespace</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-namespace.html" title="51.32. pg_namespace"><code class="structname">pg_namespace</code></a>.<code class="structfield">oid</code>) </p> <p> The OID of the namespace that contains this relation </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reltype</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-type.html" title="51.62. pg_type"><code class="structname">pg_type</code></a>.<code class="structfield">oid</code>) </p> <p> The OID of the data type that corresponds to this table's row type, if any (zero for indexes, which have no <code class="structname">pg_type</code> entry) </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reloftype</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-type.html" title="51.62. pg_type"><code class="structname">pg_type</code></a>.<code class="structfield">oid</code>) </p> <p> For typed tables, the OID of the underlying composite type, zero for all other relations </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relowner</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-authid.html" title="51.8. pg_authid"><code class="structname">pg_authid</code></a>.<code class="structfield">oid</code>) </p> <p> Owner of the relation </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relam</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-am.html" title="51.3. pg_am"><code class="structname">pg_am</code></a>.<code class="structfield">oid</code>) </p> <p> If this is a table or an index, the access method used (heap, B-tree, hash, etc.) </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relfilenode</code> <code class="type">oid</code> </p> <p> Name of the on-disk file of this relation; zero means this is a <span class="quote">“<span class="quote">mapped</span>”</span> relation whose disk file name is determined by low-level state </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reltablespace</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-tablespace.html" title="51.54. pg_tablespace"><code class="structname">pg_tablespace</code></a>.<code class="structfield">oid</code>) </p> <p> The tablespace in which this relation is stored. If zero, the database's default tablespace is implied. (Not meaningful if the relation has no on-disk file.) </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relpages</code> <code class="type">int4</code> </p> <p> Size of the on-disk representation of this table in pages (of size <code class="symbol">BLCKSZ</code>). This is only an estimate used by the planner. It is updated by <code class="command">VACUUM</code>, <code class="command">ANALYZE</code>, and a few DDL commands such as <code class="command">CREATE INDEX</code>. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reltuples</code> <code class="type">float4</code> </p> <p> Number of live rows in the table. This is only an estimate used by the planner. It is updated by <code class="command">VACUUM</code>, <code class="command">ANALYZE</code>, and a few DDL commands such as <code class="command">CREATE INDEX</code>. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relallvisible</code> <code class="type">int4</code> </p> <p> Number of pages that are marked all-visible in the table's visibility map. This is only an estimate used by the planner. It is updated by <code class="command">VACUUM</code>, <code class="command">ANALYZE</code>, and a few DDL commands such as <code class="command">CREATE INDEX</code>. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reltoastrelid</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-class.html" title="51.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>) </p> <p> OID of the TOAST table associated with this table, 0 if none. The TOAST table stores large attributes <span class="quote">“<span class="quote">out of line</span>”</span> in a secondary table. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relhasindex</code> <code class="type">bool</code> </p> <p> True if this is a table and it has (or recently had) any indexes </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relisshared</code> <code class="type">bool</code> </p> <p> True if this table is shared across all databases in the cluster. Only certain system catalogs (such as <code class="structname">pg_database</code>) are shared. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relpersistence</code> <code class="type">char</code> </p> <p> <code class="literal">p</code> = permanent table, <code class="literal">u</code> = unlogged table, <code class="literal">t</code> = temporary table </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relkind</code> <code class="type">char</code> </p> <p> <code class="literal">r</code> = ordinary table, <code class="literal">i</code> = index, <code class="literal">S</code> = sequence, <code class="literal">t</code> = TOAST table, <code class="literal">v</code> = view, <code class="literal">m</code> = materialized view, <code class="literal">c</code> = composite type, <code class="literal">f</code> = foreign table, <code class="literal">p</code> = partitioned table, <code class="literal">I</code> = partitioned index </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relnatts</code> <code class="type">int2</code> </p> <p> Number of user columns in the relation (system columns not counted). There must be this many corresponding entries in <code class="structname">pg_attribute</code>. See also <code class="literal">pg_attribute.attnum</code>. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relchecks</code> <code class="type">int2</code> </p> <p> Number of <code class="literal">CHECK</code> constraints on the table; see <a class="link" href="catalog-pg-constraint.html" title="51.13. pg_constraint"><code class="structname">pg_constraint</code></a> catalog </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relhasrules</code> <code class="type">bool</code> </p> <p> True if table has (or once had) rules; see <a class="link" href="catalog-pg-rewrite.html" title="51.43. pg_rewrite"><code class="structname">pg_rewrite</code></a> catalog </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relhastriggers</code> <code class="type">bool</code> </p> <p> True if table has (or once had) triggers; see <a class="link" href="catalog-pg-trigger.html" title="51.56. pg_trigger"><code class="structname">pg_trigger</code></a> catalog </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relhassubclass</code> <code class="type">bool</code> </p> <p> True if table or index has (or once had) any inheritance children </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relrowsecurity</code> <code class="type">bool</code> </p> <p> True if table has row level security enabled; see <a class="link" href="catalog-pg-policy.html" title="51.37. pg_policy"><code class="structname">pg_policy</code></a> catalog </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relforcerowsecurity</code> <code class="type">bool</code> </p> <p> True if row level security (when enabled) will also apply to table owner; see <a class="link" href="catalog-pg-policy.html" title="51.37. pg_policy"><code class="structname">pg_policy</code></a> catalog </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relispopulated</code> <code class="type">bool</code> </p> <p> True if relation is populated (this is true for all relations other than some materialized views) </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relreplident</code> <code class="type">char</code> </p> <p> Columns used to form <span class="quote">“<span class="quote">replica identity</span>”</span> for rows: <code class="literal">d</code> = default (primary key, if any), <code class="literal">n</code> = nothing, <code class="literal">f</code> = all columns, <code class="literal">i</code> = index with <code class="structfield">indisreplident</code> set (same as nothing if the index used has been dropped) </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relispartition</code> <code class="type">bool</code> </p> <p> True if table or index is a partition </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relrewrite</code> <code class="type">oid</code> (references <a class="link" href="catalog-pg-class.html" title="51.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">oid</code>) </p> <p> For new relations being written during a DDL operation that requires a table rewrite, this contains the OID of the original relation; otherwise 0. That state is only visible internally; this field should never contain anything other than 0 for a user-visible relation. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relfrozenxid</code> <code class="type">xid</code> </p> <p> All transaction IDs before this one have been replaced with a permanent (<span class="quote">“<span class="quote">frozen</span>”</span>) transaction ID in this table. This is used to track whether the table needs to be vacuumed in order to prevent transaction ID wraparound or to allow <code class="literal">pg_xact</code> to be shrunk. Zero (<code class="symbol">InvalidTransactionId</code>) if the relation is not a table. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relminmxid</code> <code class="type">xid</code> </p> <p> All multixact IDs before this one have been replaced by a transaction ID in this table. This is used to track whether the table needs to be vacuumed in order to prevent multixact ID wraparound or to allow <code class="literal">pg_multixact</code> to be shrunk. Zero (<code class="symbol">InvalidMultiXactId</code>) if the relation is not a table. </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relacl</code> <code class="type">aclitem[]</code> </p> <p> Access privileges; see <a class="xref" href="ddl-priv.html" title="5.7. Privileges">Section 5.7</a> for details </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">reloptions</code> <code class="type">text[]</code> </p> <p> Access-method-specific options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition"> <code class="structfield">relpartbound</code> <code class="type">pg_node_tree</code> </p> <p> If table is a partition (see <code class="structfield">relispartition</code>), internal representation of the partition bound </p></td></tr></tbody></table></div></div><br class="table-break" /><p> Several of the Boolean flags in <code class="structname">pg_class</code> are maintained lazily: they are guaranteed to be true if that's the correct state, but may not be reset to false immediately when the condition is no longer true. For example, <code class="structfield">relhasindex</code> is set by <code class="command">CREATE INDEX</code>, but it is never cleared by <code class="command">DROP INDEX</code>. Instead, <code class="command">VACUUM</code> clears <code class="structfield">relhasindex</code> if it finds the table has no indexes. This arrangement avoids race conditions and improves concurrency. </p></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-cast.html" title="51.10. pg_cast">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html" title="Chapter 51. System Catalogs">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-collation.html" title="51.12. pg_collation">Next</a></td></tr><tr><td width="40%" align="left" valign="top">51.10. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_cast</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 13.1 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 51.12. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_collation</code></td></tr></table></div></body></html>