Flashback Table
Oracle Flashback Table
FLASHBACK TABLE is an Oracle DDL/DML command that rewinds an entire table — including its row data — to a previous snapshot, using the undo segments still available in the instance. Unlike a traditional restore, it operates at the logical level and requires no database downtime.
How it works #
The command reads the undo blocks generated by transactions after the target point and applies them in reverse order to the table. Two prerequisites must be met: the table must have ROW MOVEMENT enabled (required to reassign ROWIDs during the rewind), and the undo data must still be present in the UNDO tablespace — not yet overwritten by more recent transactions.
-- Prerequisite: enable ROW MOVEMENT
ALTER TABLE orders ENABLE ROW MOVEMENT;
-- Restore to a specific timestamp
FLASHBACK TABLE orders TO TIMESTAMP
TO_TIMESTAMP('2025-06-10 14:30:00', 'YYYY-MM-DD HH24:MI:SS');
-- Restore to a specific SCN
FLASHBACK TABLE orders TO SCN 9823741;
When to use it #
The typical scenario is recovery from an application or human error: a DELETE or UPDATE run without the correct WHERE clause, or an accidental TRUNCATE (the latter is only recoverable if the table was dropped and FLASHBACK DROP is used instead). The command is appropriate when:
- the time window is short (bounded by the configured
UNDO_RETENTION); - only a single table needs to be restored without touching others;
- active sessions on other tables must not be interrupted.
Two key limitations apply: the operation fails if the required undo data has already been overwritten, and it does not handle referential dependencies — if the table has foreign keys pointing to other tables that were also modified in the interim, the restore may produce integrity violations that must be resolved manually.