summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/catalog-pg-class.html
blob: 487873968c7df386f7c435b1f577772cfd2e6f98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?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>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 15.7 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></h2></div></div></div><a id="id-1.10.4.13.2" class="indexterm"></a><p>
   The catalog <code class="structname">pg_class</code> describes tables and
   other objects that have columns or are otherwise similar to a
   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>),
   sequences (but see also <a class="link" href="catalog-pg-sequence.html" title="53.47. pg_sequence"><code class="structname">pg_sequence</code></a>),
   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 of <code class="structname">pg_class</code>'s
   columns are meaningful for all relation kinds.
  </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">
       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="53.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="53.64. 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, sequences, and toast tables, 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="53.64. 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="53.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="53.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.); otherwise zero (zero occurs for sequences,
       as well as relations without storage, such as views)
      </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="53.56. 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,
       except for partitioned tables, where this is the tablespace
       in which partitions will be created when one is not
       specified in the creation command.
      </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 <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
       <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
       <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
      </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 <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
       <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
       <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
       If the table has never yet been vacuumed or
       analyzed, <code class="structfield">reltuples</code>
       contains <code class="literal">-1</code> indicating that the row count is
       unknown.
      </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 <a class="link" href="sql-vacuum.html" title="VACUUM"><code class="command">VACUUM</code></a>,
       <a class="link" href="sql-analyze.html" title="ANALYZE"><code class="command">ANALYZE</code></a>, and a few DDL commands such as
       <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>.
      </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="53.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, zero 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 <a class="link" href="catalog-pg-database.html" title="53.15. pg_database"><code class="structname">pg_database</code></a>)
       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/sequence, <code class="literal">u</code> = unlogged table/sequence,
       <code class="literal">t</code> = temporary table/sequence
      </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
       <a class="link" href="catalog-pg-attribute.html" title="53.7. pg_attribute"><code class="structname">pg_attribute</code></a>.  See also
       <code class="structname">pg_attribute</code>.<code class="structfield">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="53.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="53.45. 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="53.58. 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 or partitions
      </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="53.38. 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="53.38. 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="53.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 zero.  That state is only visible internally; this field should
       never contain anything other than zero 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
   <a class="link" href="sql-createindex.html" title="CREATE INDEX"><code class="command">CREATE INDEX</code></a>, but it is never cleared by
   <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
   <code class="structfield">relhasindex</code> if it finds the table has no indexes.  This
   arrangement avoids race conditions and improves concurrency.
  </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 15.7 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>