合 PG查看和设置事务的隔离级别
查看和设置PG的事务隔离级别
事务内容请参考:https://www.dbaup.com/pgzhongdeshiwu.html
PG默认的事务隔离级别为Read Committed。
数据库隔离级别
查看全局事务隔离级别
1 2 3 4 5 6 7 8 9 10 11 | postgres=# select current_setting('default_transaction_isolation'); current_setting ----------------- read committed (1 row) postgres=# SELECT name,setting FROM pg_settings WHERE name='default_transaction_isolation'; name | setting -------------------------------+---------------- default_transaction_isolation | read committed (1 row) |
修改全局事务隔离级别
方法一:修改postgresql.conf文件中的default_transaction_isolation参数。
方法二:通过alter system修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | postgres=# alter system set default_transaction_isolation to 'REPEATABLE READ'; ALTER SYSTEM postgres=# select pg_reload_conf(); pg_reload_conf ---------------- t (1 row) postgres=# select current_setting('default_transaction_isolation'); current_setting ----------------- repeatable read (1 row) postgres=# alter system set default_transaction_isolation to 'read committed'; ALTER SYSTEM postgres=# postgres=# select pg_reload_conf(); pg_reload_conf ---------------- t (1 row) postgres=# select current_setting('default_transaction_isolation'); current_setting ----------------- read committed (1 row) |