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 ✨
WORKTRANSACTION— optional key words, bestie. They have no effect. They're just there. Decorative. Little garnish words. 🎀AND CHAIN— if you sayAND 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 (peepSET TRANSACTION(SET_TRANSACTION(7))) for what "characteristics" means, iykyk). If you don't sayAND 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 ✨
BEGIN(7)COMMIT(7)ROLLBACK TO SAVEPOINT(ROLLBACK_TO_SAVEPOINT(7))
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 💖✨🎀
📦 where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 · PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 · PostgreSQL
- arch rolling: postgresql 18.6-4 · PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 · PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 · PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 · PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 · PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 · PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 · PostgreSQL
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms