ROLLBACK(7)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸŽ€ ROLLBACK πŸ’…

okay so bestie, welcome to the ROLLBACK page β€” it's a PostgreSQL 14.24 classic and honestly it's giving "undo button of the soul" energy. No cap, this one's short but iconic.


✨ SYNOPSIS ✨

ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]

πŸ¦‹ DESCRIPTION πŸ¦‹

ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded. that's it. that's the whole vibe. everything you did in there? gone. poof. πŸ’€

like literally, it undoes the entire transaction β€” every change gets tossed. main character energy for the undo.


🌸 PARAMETERS 🌸

  • WORK
  • TRANSACTION

these two are optional key words and they have no effect whatsoever. 🫢 they're just there. decorative. aesthetic. they do nothing and honestly? relatable.

  • AND CHAIN

if you specify AND CHAIN, a new transaction is immediately started with the same transaction characteristics as the one that just finished (see SET TRANSACTION β€” that's SET_TRANSACTION(7) if you wanna look it up πŸ’–). otherwise, no new transaction is started. so like, chain = you're immediately back in another transaction with the same settings. no chain = you're free, you're outside, you're unbothered. ✨


πŸ’œ NOTES πŸ’œ

use COMMIT to successfully terminate a transaction. that's the "yay we did it, keep the changes" sibling. 🌈

ngl this next bit matters: issuing ROLLBACK outside of a transaction block emits a warning and otherwise has no effect. and ROLLBACK AND CHAIN outside of a transaction block is an error β€” not a warning, an actual error. so like, know where you are before you start rolling back, bestie. πŸ™ˆ

πŸ“ EXAMPLES πŸ“

to abort all changes:

ROLLBACK;

that's it. one line. bye. πŸ˜­πŸ‘‘


⭐ COMPATIBILITY ⭐

the command ROLLBACK conforms to the SQL standard, slay. πŸ’… but heads up β€” the form ROLLBACK TRANSACTION is a PostgreSQL extension. so that one's a Postgres-only little treat, iykyk. 🧚


πŸ”₯ SEE ALSO πŸ”₯

BEGIN(7), COMMIT(7), ROLLBACK TO SAVEPOINT β€” that's ROLLBACK_TO_SAVEPOINT(7) πŸ¦‹


this has been PostgreSQL 14.24, dated 2026 β€” ROLLBACK documentation, rewritten with love πŸ«ΆπŸ’– mwah, go forth and undo responsibly ✨

πŸ“¦ where this page comes from