4.2、提交事务
进程#1访问
postgres=# begin;
BEGIN
postgres=# delete from tbase where id=5;
DELETE 1
postgres=#
postgres=# select * from tbase order by id;
id | nickname
----+---------------
1 | hello TBase
2 | TBase好
3 | TBase好
4 | TBase default
TBase也是完全支持ACID特性,没提交前开启另一个连接查询,你会看到是5条记录,这是TBase隔离性和多版本视图的实现,如下所示
进程#2访问
postgres=# select * from tbase order by id;
id | nickname
----+---------------
1 | hello TBase
2 | TBase好
3 | TBase好
4 | TBase default
5 | TBase swap
(5 rows)
进程#1提交数据
postgres=# commit;
COMMIT
postgres=#
进程#2再查询数据,这时能看到已经提交的数据了,这个级别叫“读已提交”
postgres=# select * from tbase order by id;
id | nickname
----+---------------
1 | hello TBase
2 | TBase好
3 | TBase好
4 | TBase default
(4 rows)