ROLLBACK(7)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… 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 ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from