summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ddl-system-columns.html
blob: ab773d3aeb8381f9a3e2e1fb77a3f3aa56709458 (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
<?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>5.5. 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.4. Constraints" /><link rel="next" href="ddl-alter.html" title="5.6. 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.5. System Columns</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ddl-constraints.html" title="5.4. 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 15.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ddl-alter.html" title="5.6. 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.5. System Columns</h2></div></div></div><p>
   Every table has several <em class="firstterm">system columns</em> that are
   implicitly defined by the system.  Therefore, these names cannot be
   used as names of user-defined columns.  (Note that these
   restrictions are separate from whether the name is a key word or
   not; quoting a name will not allow you to escape these
   restrictions.)  You do not really need to be concerned about these
   columns; just know they exist.
  </p><a id="id-1.5.4.7.3" class="indexterm"></a><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="structfield">tableoid</code></span></dt><dd><a id="id-1.5.4.7.4.1.2.1" class="indexterm"></a><p>
      The OID of the table containing this row.  This column is
      particularly handy for queries that select from partitioned
      tables (see <a class="xref" href="ddl-partitioning.html" title="5.11. Table Partitioning">Section 5.11</a>) or inheritance
      hierarchies (see <a class="xref" href="ddl-inherit.html" title="5.10. Inheritance">Section 5.10</a>), since without it,
      it's difficult to tell which individual table a row came from.  The
      <code class="structfield">tableoid</code> can be joined against the
      <code class="structfield">oid</code> column of
      <code class="structname">pg_class</code> to obtain the table name.
     </p></dd><dt><span class="term"><code class="structfield">xmin</code></span></dt><dd><a id="id-1.5.4.7.4.2.2.1" class="indexterm"></a><p>
      The identity (transaction ID) of the inserting transaction for
      this row version.  (A row version is an individual state of a
      row; each update of a row creates a new row version for the same
      logical row.)
     </p></dd><dt><span class="term"><code class="structfield">cmin</code></span></dt><dd><a id="id-1.5.4.7.4.3.2.1" class="indexterm"></a><p>
      The command identifier (starting at zero) within the inserting
      transaction.
     </p></dd><dt><span class="term"><code class="structfield">xmax</code></span></dt><dd><a id="id-1.5.4.7.4.4.2.1" class="indexterm"></a><p>
      The identity (transaction ID) of the deleting transaction, or
      zero for an undeleted row version.  It is possible for this column to
      be nonzero in a visible row version. That usually indicates that the
      deleting transaction hasn't committed yet, or that an attempted
      deletion was rolled back.
     </p></dd><dt><span class="term"><code class="structfield">cmax</code></span></dt><dd><a id="id-1.5.4.7.4.5.2.1" class="indexterm"></a><p>
      The command identifier within the deleting transaction, or zero.
     </p></dd><dt><span class="term"><code class="structfield">ctid</code></span></dt><dd><a id="id-1.5.4.7.4.6.2.1" class="indexterm"></a><p>
      The physical location of the row version within its table.  Note that
      although the <code class="structfield">ctid</code> can be used to
      locate the row version very quickly, a row's
      <code class="structfield">ctid</code> will change if it is
      updated or moved by <code class="command">VACUUM FULL</code>.  Therefore
      <code class="structfield">ctid</code> is useless as a long-term row
      identifier.  A primary key should be used to identify logical rows.
     </p></dd></dl></div><p>
    Transaction identifiers are also 32-bit quantities.  In a
    long-lived database it is possible for transaction IDs to wrap
    around.  This is not a fatal problem given appropriate maintenance
    procedures; see <a class="xref" href="maintenance.html" title="Chapter 25. Routine Database Maintenance Tasks">Chapter 25</a> for details.  It is
    unwise, however, to depend on the uniqueness of transaction IDs
    over the long term (more than one billion transactions).
   </p><p>
    Command identifiers are also 32-bit quantities.  This creates a hard limit
    of 2<sup>32</sup> (4 billion) <acronym class="acronym">SQL</acronym> commands
    within a single transaction.  In practice this limit is not a
    problem — note that the limit is on the number of
    <acronym class="acronym">SQL</acronym> commands, not the number of rows processed.
    Also, only commands that actually modify the database contents will
    consume a command identifier.
   </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.4. 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.6. Modifying Tables">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.4. Constraints </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 5.6. Modifying Tables</td></tr></table></div></body></html>