]> begriffs open source - ai-pg/blob - full-docs/txt/ddl-system-columns.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / ddl-system-columns.txt
1
2 5.6. System Columns #
3
4    Every table has several system columns that are implicitly defined by
5    the system. Therefore, these names cannot be used as names of
6    user-defined columns. (Note that these restrictions are separate from
7    whether the name is a key word or not; quoting a name will not allow
8    you to escape these restrictions.) You do not really need to be
9    concerned about these columns; just know they exist.
10
11    tableoid #
12           The OID of the table containing this row. This column is
13           particularly handy for queries that select from partitioned
14           tables (see Section 5.12) or inheritance hierarchies (see
15           Section 5.11), since without it, it's difficult to tell which
16           individual table a row came from. The tableoid can be joined
17           against the oid column of pg_class to obtain the table name.
18
19    xmin #
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
25    cmin #
26           The command identifier (starting at zero) within the inserting
27           transaction.
28
29    xmax #
30           The identity (transaction ID) of the deleting transaction, or
31           zero for an undeleted row version. It is possible for this
32           column to be nonzero in a visible row version. That usually
33           indicates that the deleting transaction hasn't committed yet, or
34           that an attempted deletion was rolled back.
35
36    cmax #
37           The command identifier within the deleting transaction, or zero.
38
39    ctid #
40           The physical location of the row version within its table. Note
41           that although the ctid can be used to locate the row version
42           very quickly, a row's ctid will change if it is updated or moved
43           by VACUUM FULL. Therefore ctid is useless as a long-term row
44           identifier. A primary key should be used to identify logical
45           rows.
46
47    Transaction identifiers are also 32-bit quantities. In a long-lived
48    database it is possible for transaction IDs to wrap around. This is not
49    a fatal problem given appropriate maintenance procedures; see
50    Chapter 24 for details. It is unwise, however, to depend on the
51    uniqueness of transaction IDs over the long term (more than one billion
52    transactions).
53
54    Command identifiers are also 32-bit quantities. This creates a hard
55    limit of 2^32 (4 billion) SQL commands within a single transaction. In
56    practice this limit is not a problem — note that the limit is on the
57    number of SQL commands, not the number of rows processed. Also, only
58    commands that actually modify the database contents will consume a
59    command identifier.