Postgresql的隐藏系统列(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-04-20 03:42 点击:次
2 | 2 | 1853 | 0 | (0,6) | 6 | aa
3 | 3 | 1853 | 0 | (0,7) | 7 | aad
这里我们可以看到cmin和cmax值有了变化
postgres=# begin; www.2cto.com
BEGIN
postgres=# update test set name = 'keke' where id = 7;
UPDATE 1
postgres=# update test set name = 'kekeke' where id = 6;
UPDATE 1
postgres=# update test set name = 'kenyon_test' where id = 5;
UPDATE 1
在另外一个会话中我们去查看xmax值
postgres=# select cmin,cmax,xmin,xmax,ctid,* from test;
cmin | cmax | xmin | xmax | ctid | id | name
------+------+------+------+-------+----+--------------
0 | 0 | 1852 | 0 | (0,1) | 1 | kenyonkenyon
0 | 0 | 1852 | 0 | (0,2) | 2 | kenyonkenyon
0 | 0 | 1852 | 0 | (0,3) | 3 | kenyonkenyon
0 | 0 | 1853 | 0 | (0,4) | 4 | a
2 | 2 | 1853 | 1854 | (0,5) | 5 | aa
1 | 1 | 1853 | 1854 | (0,6) | 6 | aa
0 | 0 | 1853 | 1854 | (0,7) | 7 | aad
(7 rows)
原会话中我们执行commit并查看
postgres=# commit;
COMMIT
postgres=# select cmin,cmax,xmin,xmax,ctid,* from test;
cmin | cmax | xmin | xmax | ctid | id | name
------+------+------+------+--------+----+--------------
0 | 0 | 1852 | 0 | (0,1) | 1 | kenyonkenyon
0 | 0 | 1852 | 0 | (0,2) | 2 | kenyonkenyon
0 | 0 | 1852 | 0 | (0,3) | 3 | kenyonkenyon
0 | 0 | 1853 | 0 | (0,4) | 4 | a
0 | 0 | 1854 | 0 | (0,8) | 7 | keke
1 | 1 | 1854 | 0 | (0,9) | 6 | kekeke
2 | 2 | 1854 | 0 | (0,10) | 5 | kenyon_test
(7 rows)
这时我们可以看到ctid也有了变化,在原来的基础上(0,7)往上累积,另外xmax因为事务被commit 的缘故也被置为0了。 再做下delete和insert的一个简单操作
postgres=# delete from test where id = 1; www.2cto.com
DELETE 1
postgres=# insert into test values (8,'jackson');
INSERT 0 1
postgres=# select cmin,cmax,xmin,xmax,ctid,* from test;
cmin | cmax | xmin | xmax | ctid | id | name
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>