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
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms