Saturday, August 8, 2009

turn off autocommit for psql

Every time I fire up a new instance of postgres, I forget how to turn off autocommit for psql. Searching on it, mostly I found a series of people saying "just begin a transaction." This makes NO sense! All it takes is one time of forgetting to begin a transaction, then one forgotten or ill-formed where clause on your delete statement and you're sitting on the floor crying. I am not sure why this is the default. So here is a post that will hopefully bubble above the People Not Answering The Question.

Anyways, it's pretty easy. Just

cd ~
vim .psqlrc
and make it look like this
SET AUTOCOMMIT OFF
viola! Now you may enjoy the wonders of Postgres (including transactional ddl, my favorite), without having to keep looking over your shoulder.

1 comment: