ROLLBACK(7)

💅 ROLLBACK — the manual page, bestie edition

okay so you opened ROLLBACK(7) from the PostgreSQL 18.6 Documentation and you're like "what does this do" — bestie, it's the undo button. The big one. Let's go. 🦋


✨ NAME ✨

ROLLBACK — abort the current transaction

Like. Just. Nope out of it. 🫶


✨ SYNOPSIS ✨

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

That's the whole vibe. Two optional chunks, both square-bracketed, both living their best life. 🌸


✨ DESCRIPTION ✨

ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded.

Not "some". Not "the ones you regret". All of them. The transaction goes poof, everything it touched goes poof with it. It's giving Ctrl+Z but with main character energy. 💀


✨ PARAMETERS ✨

  • WORK
  • TRANSACTION — optional key words, bestie. They have no effect. They're just there. Decorative. Little garnish words. 🎀
  • AND CHAIN — if you say AND CHAIN, then a new transaction starts immediately — and important: it's a new, not aborted transaction — and it carries the same transaction characteristics as the one that just finished (peep SET TRANSACTION (SET_TRANSACTION(7))) for what "characteristics" means, iykyk). If you don't say AND CHAIN, then no new transaction is started. That's it. That's the whole deal. ✨

✨ NOTES ✨

Wanna end a transaction the happy way? That's COMMIT, babe. Different page, different vibe. 🌈

Now, the tea: if you issue ROLLBACK outside of a transaction block, it emits a warning and otherwise has no effect. So it's not a crime, it's just… nothing. A little warning. A little shrug. 🙈

But ROLLBACK AND CHAIN outside of a transaction block? That's an error. Not a warning. An actual error. Do not pass go. 💀


✨ EXAMPLES ✨

To abort all changes — literally every single one — you go:

ROLLBACK;

Iconic. Clean. Slay. 👑


✨ COMPATIBILITY ✨

The command ROLLBACK conforms to the SQL standard. 💯

The form ROLLBACK TRANSACTION is a PostgreSQL extension — so that one's ours, we invented it, we're obsessed. 🧚


✨ SEE ALSO ✨

Go read those too, bestie, they're the rest of the story. 📚


PostgreSQL 18.6 · 2026 · ROLLBACK(7) — mwah, that's the whole page, thanks for coming to my TED talk, go roll something back 💖✨🎀