问题
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?
回答1:
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?
回答2:
Use a transaction if you want want a (open) transaction:
BEGIN;
INSERT ...;
UPDATE ...;
COMMIT; -- when you're done
来源:https://stackoverflow.com/questions/13837146/postgres-setting-autocommit-off-globally