Postgres setting autocommit off globally

空扰寡人 提交于 2019-12-23 08:47:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!