Postgres setting autocommit off globally

2019-06-18 15:25发布

How do you set autocommit off in psql 8.4 at a global level? is there a configuration attribute that i can change that will introduce this behaviour for all dbs on a cluster to start db sessions with autocommit off?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-18 16:04

Use a transaction if you want want a (open) transaction:

BEGIN;
  INSERT ...;
  UPDATE ...;
COMMIT; -- when you're done
查看更多
唯我独甜
3楼-- · 2019-06-18 16:14

Simply add the following to ~/.psqlrc:

\set AUTOCOMMIT off 

Note that this only works when using the psql shell! I assume this is what you are talking about?

查看更多
登录 后发表回答