Oracle UNDO vs REDO: The Difference, Explained
Undo stores what a row looked like before your change, powering rollback and read consistency. Redo records every change for crash recovery. They sound similar but solve opposite problems — and undo itself generates redo, which is the detail that catches people out.
Two logs, two different jobs
Undo and redo are Oracle's two change-tracking mechanisms, and they solve opposite problems. Undo stores before-images of changed data — what a row looked like before your transaction touched it. Redo records every change made to the database, committed or not, so the instance can recover after a crash.
UNDO vs REDO at a glance
| UNDO | REDO | |
|---|---|---|
| Stores | the before-image of changed data | a record of every change made |
| Purpose | rollback, read consistency, flashback queries | crash recovery, durability (the "D" in ACID) |
| Location | the UNDO tablespace (undo segments) | online redo log files |
| Written for | your own transaction's changes, to undo them if needed | all changes, so committed work survives a crash even if not yet on disk |
| Read by other sessions? | yes — powers read consistency for concurrent queries (MVCC) | no — redo is for recovery, not queried during normal operation |
Why the database needs both
Redo is what makes a COMMIT durable: Oracle writes the change to the redo log before confirming the commit, so even if the instance crashes before the actual data block is written to disk, the committed change can be replayed from redo during recovery. This is standard write-ahead logging.
Undo is what makes ROLLBACK possible, and what lets another session read a consistent snapshot of a row while your transaction is still mid-flight, uncommitted — Oracle shows them the undo (before-image) version instead of your in-progress change.
The fact that trips people up: undo generates redo too
Because undo segments are themselves part of the database, changes to them also need to be durable and recoverable — so writing an undo record also generates a redo entry. A single row update therefore produces both an undo record (to allow rollback) and redo entries covering both the data change and the undo change itself. This is a common exam and interview point precisely because it's counter-intuitive at first.