日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

postgresql 事务隔离级别 set transaction isolation level

發布時間:2024/3/7 编程问答 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postgresql 事务隔离级别 set transaction isolation level 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

os: centos 7.4
db: postgresql 10.11

postgresql 默認的 isolation level 為 read committed,可以調整隔離級別。

版本

# cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) # # # su - postgres Last login: Wed Jan 15 18:34:12 CST 2020 on pts/0 $ $ $ psql -c "select version();"version ----------------------------------------------------------------------------------------------------------PostgreSQL 10.11 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit (1 row)

set transaction isolation level

postgres=# select name,setting from pg_settings where name like 'transaction%';name | setting ------------------------+----------------transaction_deferrable | offtransaction_isolation | read committedtransaction_read_only | off (3 rows)postgres=# \h set transaction Command: SET TRANSACTION Description: set the characteristics of the current transaction Syntax: SET TRANSACTION transaction_mode [, ...] SET TRANSACTION SNAPSHOT snapshot_id SET SESSION CHARACTERISTICS AS TRANSACTION transaction_mode [, ...]where transaction_mode is one of:ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }READ WRITE | READ ONLY[ NOT ] DEFERRABLE postgres=# set transaction isolation level serializable; WARNING: SET TRANSACTION can only be used in transaction blocks SET

serializable

postgres=# begin; postgres=# set transaction isolation level serializable; postgres=# show transaction_isolation;transaction_isolation -----------------------serializable (1 row)postgres=# rollback;

repeatable read

postgres=# begin; postgres=# set transaction isolation level repeatable read; postgres=# show transaction_isolation;transaction_isolation -----------------------repeatable read (1 row)postgres=# rollback;

read committed

postgres=# begin; postgres=# set transaction isolation level read committed; postgres=# show transaction_isolation;transaction_isolation -----------------------read committed (1 row)postgres=# rollback;

read uncommitted

postgres=# begin; postgres=# set transaction isolation level read uncommitted; postgres=# show transaction_isolation;transaction_isolation -----------------------read uncommitted (1 row)postgres=# rollback;

begin

postgres=# \h begin Command: BEGIN Description: start a transaction block Syntax: BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]where transaction_mode is one of:ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }READ WRITE | READ ONLY[ NOT ] DEFERRABLE

serializable

postgres=# begin transaction isolation level serializable; postgres=# show transaction_isolation;transaction_isolation -----------------------serializable (1 row)postgres=# rollback;

repeatable read

postgres=# begin transaction isolation level repeatable read; postgres=# show transaction_isolation;transaction_isolation -----------------------repeatable read (1 row)postgres=# rollback;

read committed

postgres=# begin transaction isolation level read committed; postgres=# show transaction_isolation;transaction_isolation -----------------------read committed (1 row)postgres=# rollback;

read uncommitted

postgres=# begin transaction isolation level read uncommitted; postgres=# show transaction_isolation;transaction_isolation -----------------------read uncommitted (1 row)postgres=# rollback;

參考:
http://postgres.cn/docs/10/sql-set-transaction.html

總結

以上是生活随笔為你收集整理的postgresql 事务隔离级别 set transaction isolation level的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。