Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres setting autocommit off globally

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?

like image 325
ajeeshpu Avatar asked Dec 12 '12 09:12

ajeeshpu


People also ask

How do I turn off autocommit?

To disable autocommit mode explicitly, use the following statement: SET autocommit=0; After disabling autocommit mode by setting the autocommit variable to zero, changes to transaction-safe tables (such as those for InnoDB or NDB ) are not made permanent immediately.

How do I turn off auto commit in pgAdmin?

with pgAdmin 4, you can click the “down” arrow next to the. icon in the query tool to turn off autocommit. with DBeaver, you can click the. icon in the SQL editor to disable autocommit.

How do you check autocommit is on or off?

To tell if AUTOCOMMIT is on or off, issue the set command: $ \set ... AUTOCOMMIT = 'off' ... AUTOCOMMIT is off if a SELECT * FROM LOCKS shows locks from the statement you just ran.


1 Answers

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?

like image 107
exhuma Avatar answered Sep 22 '22 10:09

exhuma