I accidentally launched unwanted UPDATE query inside psql (9.4) and killed it with CTRL+C a few seconds later. Were there any records modified, or it's all or nothing?

2 Answers 2


A statement is always atomic. That is true for all DML statements and nearly all DDL statements.

So either everything succeeds or nothing. If you interrupt it halfway through, everything that was changed until then will be rolled back.


In addition to @a_horse_with_no_name answer I can say that every statement you type in psql console is wrapped by BEGIN; and COMMIT; by default. And the same thing applies to single statements outside of any transaction block sent to postgres port.

So no, there is no way to perform action partly in postgres.

Also, you can adjust behavior of psql regarding BEGIN; and END; with adding this parameter to your ~/.psqlrc file:


With this option turned off you'll need to manually COMMIT after every write statement which can help you avoid mistakes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.