postgresql system column

  PostgreSQL tables have some columns (system columns) that are hidden by default. The names of these columns cannot be used like user-defined columns, but they play a pivotal role within the database.

	zijie=> select tableoid,ctid,cmin,cmax,xmin,xmax,id from t1;
 tableoid | ctid  | cmin | cmax | xmin | xmax | id
----------+-------+------+------+------+------+----
    16419 | (0,1) |    0 |    0 |  511 |    0 |  1
    16419 | (0,2) |    0 |    0 |  512 |    0 |  2
    16419 | (0,3) |    0 |    0 |  513 |    0 |  3
    16419 | (0,4) |    0 |    0 |  514 |    0 |  4
    16419 | (0,5) |    0 |    0 |  515 |    0 |  5
(5 rows)

tableoid

包含这一行的表的OID。如果没有tableoid将很难知道一行来自于哪个表。tableoid可以与pg_class的oid列进行连接来获得表的名称。

xmin

插入该行版本的事务身份(事务ID)。一个行版本是一个行的一个特别版本,对一个逻辑行的每一次更新都将创建一个新的行版本。 

cmin

插入事务中的命令标识符(从0开始)。 

xmax

删除事务的身份(事务ID),对于未删除的行版本为0。对于一个可见的行版本,该列值也可能为非零。这通常表示删除事务还没有提交,或者一个删除尝试被回滚。 

cmax

删除事务中的命令标识符,或者为0。 

ctid

行版本在其表中的物理位置。注意尽管ctid可以被用来非常快速地定位行版本,但是一个行的ctid会在被更新或者被VACUUM FULL移动时改变。因此,ctid不能作为一个长期行标识符。 应使用主键来标识逻辑行。 

Guess you like

Origin blog.csdn.net/qq_42979842/article/details/108313163
Recommended