]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/catalog-pg-class.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / catalog-pg-class.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.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="52.10. pg_cast" /><link rel="next" href="catalog-pg-collation.html" title="52.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">52.11. <code class="structname">pg_class</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-cast.html" title="52.10. pg_cast">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-collation.html" title="52.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">52.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 and
4    other objects that have columns or are otherwise similar to a
5    table.  This includes indexes (but see also <a class="link" href="catalog-pg-index.html" title="52.26. pg_index"><code class="structname">pg_index</code></a>),
6    sequences (but see also <a class="link" href="catalog-pg-sequence.html" title="52.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 of
10    <span class="quote">“<span class="quote">relations</span>”</span>.  Not all of <code class="structname">pg_class</code>'s
11    columns are meaningful for all relation kinds.
12   </p><div class="table" id="id-1.10.4.13.4"><p class="title"><strong>Table 52.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 Type
14       </p>
15       <p>
16        Description
17       </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 identifier
22       </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="52.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 relation
33       </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="52.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 have
40        no <code class="structname">pg_type</code> entry
41       </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="52.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 relations
48       </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="52.8. pg_authid"><code class="structname">pg_authid</code></a>.<code class="structfield">oid</code>)
51       </p>
52       <p>
53        Owner of the relation
54       </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="52.3. pg_am"><code class="structname">pg_am</code></a>.<code class="structfield">oid</code>)
57       </p>
58       <p>
59        The access method used to access this table or index.
60        Not meaningful if the relation is a sequence or
61        has no on-disk file,
62        except for partitioned tables, where, if set, it takes
63        precedence over <code class="varname">default_table_access_method</code>
64        when determining the access method to use for partitions created
65        when one is not specified in the creation command.
66       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
67        <code class="structfield">relfilenode</code> <code class="type">oid</code>
68       </p>
69       <p>
70        Name of the on-disk file of this relation; zero means this
71        is a <span class="quote">“<span class="quote">mapped</span>”</span> relation whose disk file name is determined
72        by low-level state
73       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
74        <code class="structfield">reltablespace</code> <code class="type">oid</code>
75        (references <a class="link" href="catalog-pg-tablespace.html" title="52.56. pg_tablespace"><code class="structname">pg_tablespace</code></a>.<code class="structfield">oid</code>)
76       </p>
77       <p>
78        The tablespace in which this relation is stored.
79        If zero, the database's default tablespace is implied.
80        Not meaningful if the relation has no on-disk file,
81        except for partitioned tables, where this is the tablespace
82        in which partitions will be created when one is not
83        specified in the creation command.
84       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
85        <code class="structfield">relpages</code> <code class="type">int4</code>
86       </p>
87       <p>
88        Size of the on-disk representation of this table in pages (of size
89        <code class="symbol">BLCKSZ</code>).  This is only an estimate used by the
90        planner.  It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
91        <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
92        <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
93       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
94        <code class="structfield">reltuples</code> <code class="type">float4</code>
95       </p>
96       <p>
97        Number of live rows in the table.  This is only an estimate used by
98        the planner.  It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
99        <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
100        <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
101        If the table has never yet been vacuumed or
102        analyzed, <code class="structfield">reltuples</code>
103        contains <code class="literal">-1</code> indicating that the row count is
104        unknown.
105       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
106        <code class="structfield">relallvisible</code> <code class="type">int4</code>
107       </p>
108       <p>
109        Number of pages that are marked all-visible in the table's
110        visibility map.  This is only an estimate used by the
111        planner.  It is updated by <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
112        <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
113        <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
114       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
115        <code class="structfield">relallfrozen</code> <code class="type">int4</code>
116       </p>
117       <p>
118        Number of pages that are marked all-frozen in the table's visibility
119        map.  This is only an estimate used for triggering autovacuums. It can
120        also be used along with <code class="structfield">relallvisible</code> for
121        scheduling manual vacuums and tuning <a class="link" href="runtime-config-vacuum.html#RUNTIME-CONFIG-VACUUM-FREEZING" title="19.10.4. Freezing">vacuum's freezing
122        behavior</a>.
123
124        It is updated by
125        <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
126        <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>,
127        and a few DDL commands such as
128        <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
129       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
130        <code class="structfield">reltoastrelid</code> <code class="type">oid</code>
131        (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>)
132       </p>
133       <p>
134        OID of the TOAST table associated with this table, zero if none.  The
135        TOAST table stores large attributes <span class="quote">“<span class="quote">out of line</span>”</span> in a
136        secondary table.
137       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
138        <code class="structfield">relhasindex</code> <code class="type">bool</code>
139       </p>
140       <p>
141        True if this is a table and it has (or recently had) any indexes
142       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
143        <code class="structfield">relisshared</code> <code class="type">bool</code>
144       </p>
145       <p>
146        True if this table is shared across all databases in the cluster.  Only
147        certain system catalogs (such as <a class="link" href="catalog-pg-database.html" title="52.15. pg_database"><code class="structname">pg_database</code></a>)
148        are shared.
149       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
150        <code class="structfield">relpersistence</code> <code class="type">char</code>
151       </p>
152       <p>
153        <code class="literal">p</code> = permanent table/sequence, <code class="literal">u</code> = unlogged table/sequence,
154        <code class="literal">t</code> = temporary table/sequence
155       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
156        <code class="structfield">relkind</code> <code class="type">char</code>
157       </p>
158       <p>
159        <code class="literal">r</code> = ordinary table,
160        <code class="literal">i</code> = index,
161        <code class="literal">S</code> = sequence,
162        <code class="literal">t</code> = TOAST table,
163        <code class="literal">v</code> = view,
164        <code class="literal">m</code> = materialized view,
165        <code class="literal">c</code> = composite type,
166        <code class="literal">f</code> = foreign table,
167        <code class="literal">p</code> = partitioned table,
168        <code class="literal">I</code> = partitioned index
169       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
170        <code class="structfield">relnatts</code> <code class="type">int2</code>
171       </p>
172       <p>
173        Number of user columns in the relation (system columns not
174        counted).  There must be this many corresponding entries in
175        <a class="link" href="catalog-pg-attribute.html" title="52.7. pg_attribute"><code class="structname">pg_attribute</code></a>.  See also
176        <code class="structname">pg_attribute</code>.<code class="structfield">attnum</code>.
177       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
178        <code class="structfield">relchecks</code> <code class="type">int2</code>
179       </p>
180       <p>
181        Number of <code class="literal">CHECK</code> constraints on the table; see
182        <a class="link" href="catalog-pg-constraint.html" title="52.13. pg_constraint"><code class="structname">pg_constraint</code></a> catalog
183       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
184        <code class="structfield">relhasrules</code> <code class="type">bool</code>
185       </p>
186       <p>
187        True if table has (or once had) rules; see
188        <a class="link" href="catalog-pg-rewrite.html" title="52.45. pg_rewrite"><code class="structname">pg_rewrite</code></a> catalog
189       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
190        <code class="structfield">relhastriggers</code> <code class="type">bool</code>
191       </p>
192       <p>
193        True if table has (or once had) triggers; see
194        <a class="link" href="catalog-pg-trigger.html" title="52.58. pg_trigger"><code class="structname">pg_trigger</code></a> catalog
195       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
196        <code class="structfield">relhassubclass</code> <code class="type">bool</code>
197       </p>
198       <p>
199        True if table or index has (or once had) any inheritance children or partitions
200       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
201        <code class="structfield">relrowsecurity</code> <code class="type">bool</code>
202       </p>
203       <p>
204        True if table has row-level security enabled; see
205        <a class="link" href="catalog-pg-policy.html" title="52.38. pg_policy"><code class="structname">pg_policy</code></a> catalog
206       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
207        <code class="structfield">relforcerowsecurity</code> <code class="type">bool</code>
208       </p>
209       <p>
210        True if row-level security (when enabled) will also apply to table owner; see
211        <a class="link" href="catalog-pg-policy.html" title="52.38. pg_policy"><code class="structname">pg_policy</code></a> catalog
212       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
213        <code class="structfield">relispopulated</code> <code class="type">bool</code>
214       </p>
215       <p>
216        True if relation is populated (this is true for all
217        relations other than some materialized views)
218       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
219        <code class="structfield">relreplident</code> <code class="type">char</code>
220       </p>
221       <p>
222        Columns used to form <span class="quote">“<span class="quote">replica identity</span>”</span> for rows:
223        <code class="literal">d</code> = default (primary key, if any),
224        <code class="literal">n</code> = nothing,
225        <code class="literal">f</code> = all columns,
226        <code class="literal">i</code> = index with
227        <code class="structfield">indisreplident</code> set (same as nothing if the
228        index used has been dropped)
229       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
230        <code class="structfield">relispartition</code> <code class="type">bool</code>
231       </p>
232       <p>
233        True if table or index is a partition
234       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
235        <code class="structfield">relrewrite</code> <code class="type">oid</code>
236        (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>)
237       </p>
238       <p>
239        For new relations being written during a DDL operation that requires a
240        table rewrite, this contains the OID of the original relation;
241        otherwise zero.  That state is only visible internally; this field should
242        never contain anything other than zero for a user-visible relation.
243       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
244        <code class="structfield">relfrozenxid</code> <code class="type">xid</code>
245       </p>
246       <p>
247        All transaction IDs before this one have been replaced with a permanent
248        (<span class="quote">“<span class="quote">frozen</span>”</span>) transaction ID in this table.  This is used to track
249        whether the table needs to be vacuumed in order to prevent transaction
250        ID wraparound or to allow <code class="literal">pg_xact</code> to be shrunk.  Zero
251        (<code class="symbol">InvalidTransactionId</code>) if the relation is not a table.
252       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
253        <code class="structfield">relminmxid</code> <code class="type">xid</code>
254       </p>
255       <p>
256        All multixact IDs before this one have been replaced by a
257        transaction ID in this table.  This is used to track
258        whether the table needs to be vacuumed in order to prevent multixact ID
259        wraparound or to allow <code class="literal">pg_multixact</code> to be shrunk.  Zero
260        (<code class="symbol">InvalidMultiXactId</code>) if the relation is not a table.
261       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
262        <code class="structfield">relacl</code> <code class="type">aclitem[]</code>
263       </p>
264       <p>
265        Access privileges; see <a class="xref" href="ddl-priv.html" title="5.8. Privileges">Section 5.8</a> for details
266       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
267        <code class="structfield">reloptions</code> <code class="type">text[]</code>
268       </p>
269       <p>
270        Access-method-specific options, as <span class="quote">“<span class="quote">keyword=value</span>”</span> strings
271       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
272        <code class="structfield">relpartbound</code> <code class="type">pg_node_tree</code>
273       </p>
274       <p>
275        If table is a partition (see <code class="structfield">relispartition</code>),
276        internal representation of the partition bound
277       </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
278    Several of the Boolean flags in <code class="structname">pg_class</code> are maintained
279    lazily: they are guaranteed to be true if that's the correct state, but
280    may not be reset to false immediately when the condition is no longer
281    true.  For example, <code class="structfield">relhasindex</code> is set by
282    <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>, but it is never cleared by
283    <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> clears
284    <code class="structfield">relhasindex</code> if it finds the table has no indexes.  This
285    arrangement avoids race conditions and improves concurrency.
286   </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="52.10. pg_cast">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-collation.html" title="52.12. pg_collation">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.10. <code class="structname">pg_cast</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.12. <code class="structname">pg_collation</code></td></tr></table></div></body></html>