提交事务
最近更新时间: 2025-02-18 16:02:00
- 进程#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 TDSQL PG
2 |TDSQL PG好
3 |TDSQL PG好
4 |TDSQL PG default
TDSQL PG也是完全支持ACID特性,没提交前开启另一个连接查询,你会看到是5条记录,这是TDSQL PG隔离性和多版本视图的实现,如下所示:
- 进程#2访问。
postgres=# select * from tbase order by id;
id| nickname
----+---------------
1 |hello TDSQL PG
2 |TDSQL PG好
3 |TDSQL PG好
4 |TDSQL PG default
5 |TDSQL PG swap
(5 rows)
- 进程#1提交数据。
postgres=# commit;
COMMIT
postgres=#
- 进程#2再查询数据,这时能看到已经提交的数据了,这个级别叫“已读提交”。
postgres=# select * from tbase order by id;
id| nickname
----+---------------
1 |hello TDSQL PG
2 |TDSQL PG好
3 |TDSQL PG好
4 |TDSQL PG default
(4 rows)