]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/ddl-system-columns.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / ddl-system-columns.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>5.6. System Columns</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="ddl-constraints.html" title="5.5. Constraints" /><link rel="next" href="ddl-alter.html" title="5.7. Modifying Tables" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">5.6. System Columns</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ddl-constraints.html" title="5.5. Constraints">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ddl.html" title="Chapter 5. Data Definition">Up</a></td><th width="60%" align="center">Chapter 5. Data Definition</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="ddl-alter.html" title="5.7. Modifying Tables">Next</a></td></tr></table><hr /></div><div class="sect1" id="DDL-SYSTEM-COLUMNS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">5.6. System Columns <a href="#DDL-SYSTEM-COLUMNS" class="id_link">#</a></h2></div></div></div><p>
3    Every table has several <em class="firstterm">system columns</em> that are
4    implicitly defined by the system.  Therefore, these names cannot be
5    used as names of user-defined columns.  (Note that these
6    restrictions are separate from whether the name is a key word or
7    not; quoting a name will not allow you to escape these
8    restrictions.)  You do not really need to be concerned about these
9    columns; just know they exist.
10   </p><a id="id-1.5.4.8.3" class="indexterm"></a><div class="variablelist"><dl class="variablelist"><dt id="DDL-SYSTEM-COLUMNS-TABLEOID"><span class="term"><code class="structfield">tableoid</code></span> <a href="#DDL-SYSTEM-COLUMNS-TABLEOID" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.1.2.1" class="indexterm"></a><p>
11       The OID of the table containing this row.  This column is
12       particularly handy for queries that select from partitioned
13       tables (see <a class="xref" href="ddl-partitioning.html" title="5.12. Table Partitioning">Section 5.12</a>) or inheritance
14       hierarchies (see <a class="xref" href="ddl-inherit.html" title="5.11. Inheritance">Section 5.11</a>), since without it,
15       it's difficult to tell which individual table a row came from.  The
16       <code class="structfield">tableoid</code> can be joined against the
17       <code class="structfield">oid</code> column of
18       <code class="structname">pg_class</code> to obtain the table name.
19      </p></dd><dt id="DDL-SYSTEM-COLUMNS-XMIN"><span class="term"><code class="structfield">xmin</code></span> <a href="#DDL-SYSTEM-COLUMNS-XMIN" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.2.2.1" class="indexterm"></a><p>
20       The identity (transaction ID) of the inserting transaction for
21       this row version.  (A row version is an individual state of a
22       row; each update of a row creates a new row version for the same
23       logical row.)
24      </p></dd><dt id="DDL-SYSTEM-COLUMNS-CMIN"><span class="term"><code class="structfield">cmin</code></span> <a href="#DDL-SYSTEM-COLUMNS-CMIN" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.3.2.1" class="indexterm"></a><p>
25       The command identifier (starting at zero) within the inserting
26       transaction.
27      </p></dd><dt id="DDL-SYSTEM-COLUMNS-XMAX"><span class="term"><code class="structfield">xmax</code></span> <a href="#DDL-SYSTEM-COLUMNS-XMAX" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.4.2.1" class="indexterm"></a><p>
28       The identity (transaction ID) of the deleting transaction, or
29       zero for an undeleted row version.  It is possible for this column to
30       be nonzero in a visible row version. That usually indicates that the
31       deleting transaction hasn't committed yet, or that an attempted
32       deletion was rolled back.
33      </p></dd><dt id="DDL-SYSTEM-COLUMNS-CMAX"><span class="term"><code class="structfield">cmax</code></span> <a href="#DDL-SYSTEM-COLUMNS-CMAX" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.5.2.1" class="indexterm"></a><p>
34       The command identifier within the deleting transaction, or zero.
35      </p></dd><dt id="DDL-SYSTEM-COLUMNS-CTID"><span class="term"><code class="structfield">ctid</code></span> <a href="#DDL-SYSTEM-COLUMNS-CTID" class="id_link">#</a></dt><dd><a id="id-1.5.4.8.4.6.2.1" class="indexterm"></a><p>
36       The physical location of the row version within its table.  Note that
37       although the <code class="structfield">ctid</code> can be used to
38       locate the row version very quickly, a row's
39       <code class="structfield">ctid</code> will change if it is
40       updated or moved by <code class="command">VACUUM FULL</code>.  Therefore
41       <code class="structfield">ctid</code> is useless as a long-term row
42       identifier.  A primary key should be used to identify logical rows.
43      </p></dd></dl></div><p>
44     Transaction identifiers are also 32-bit quantities.  In a
45     long-lived database it is possible for transaction IDs to wrap
46     around.  This is not a fatal problem given appropriate maintenance
47     procedures; see <a class="xref" href="maintenance.html" title="Chapter 24. Routine Database Maintenance Tasks">Chapter 24</a> for details.  It is
48     unwise, however, to depend on the uniqueness of transaction IDs
49     over the long term (more than one billion transactions).
50    </p><p>
51     Command identifiers are also 32-bit quantities.  This creates a hard limit
52     of 2<sup>32</sup> (4 billion) <acronym class="acronym">SQL</acronym> commands
53     within a single transaction.  In practice this limit is not a
54     problem — note that the limit is on the number of
55     <acronym class="acronym">SQL</acronym> commands, not the number of rows processed.
56     Also, only commands that actually modify the database contents will
57     consume a command identifier.
58    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ddl-constraints.html" title="5.5. Constraints">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ddl.html" title="Chapter 5. Data Definition">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ddl-alter.html" title="5.7. Modifying Tables">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.5. Constraints </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"> 5.7. Modifying Tables</td></tr></table></div></body></html>