Suggest an editImprove this articleRefine the answer for “Why do we need an undo / rollback log?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)An **undo (or rollback) log** exists to **undo the changes** a transaction made if it ends in an error or gets rolled back (`ROLLBACK`): it stores **old versions of the data**, the state *before the changes began*. **Key point:** besides rollback, the undo log also provides transaction **atomicity** (the A in ACID) and implements **multiversion concurrency control (MVCC)**, reading "old" data while other transactions are still changing it; if the server suddenly shuts down before `COMMIT`, the undo log lets the debit be undone and the old balance restored.Shown above the full answer for quick recall.Answer (EN)ImageAn **undo (or rollback) log** exists to **undo the changes** a transaction made if it ends in an error or gets rolled back (`ROLLBACK`). It stores **old versions of the data**, the state *before the changes began*. ### How it works 1. When a transaction changes data (e.g. via `UPDATE`), the DBMS writes the rows' **previous state** into the undo log. 2. If the transaction completes successfully (`COMMIT`), the log entries can be cleared. 3. If the transaction fails, the DBMS uses the undo log to **restore the old values** and return the database to a consistent state. ### Example ```sql UPDATE users SET balance = balance - 100 WHERE id = 1; ``` If the server suddenly shuts down before `COMMIT`, the undo log lets the debit be undone and the old balance restored. Besides rollback, the undo log also helps: - provide transaction **atomicity** (the A in ACID), - implement **multiversion concurrency control (MVCC)**, reading "old" data while other transactions are still changing it. **Summary:** an undo log is **insurance for your data**, storing "what it was before" and letting you safely undo any unfinished changes.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.