Oracle Flashback

Also known as: Flashback Database

On this page 7

Oracle Flashback is a family of Oracle Database features that let administrators and developers query, compare or rewind data to an earlier point in time without restoring files from a backup. In backup & recovery for databases, it covers the gap between routine logical errors, such as a wrong UPDATE or a dropped table, and full media recovery with tools such as RMAN.

The best-known member, Flashback Database, rewinds an entire database to a past system change number (SCN) or timestamp. Other members work at the level of a single query, row history, transaction or table, and most of them rely on undo data rather than on backups.

How Oracle Flashback reconstructs past data

Oracle Flashback reconstructs past data by reading before-images of changed blocks or rows that the database already keeps for other purposes. Two storage mechanisms do almost all the work: the undo tablespace and the flashback logs in the fast recovery area.

Undo data records the previous version of every changed row so that transactions can roll back and readers obtain read-consistent views. Flashback Query, Flashback Version Query, Flashback Transaction Query and Flashback Table all read this undo, so their reach is limited by the UNDO_RETENTION parameter and by the free space in the undo tablespace.

Flashback logs are written by the RVWR (recovery writer) background process. Before a block is changed, an earlier image of that block is periodically copied into the logs. To rewind, Oracle restores those block images and then applies redo to reach the exact target SCN, which is why archived redo logs must also be available.

The following table shows the main storage sources and which features depend on each.

SourceWhat it storesFeatures that use itRetention control
Undo tablespacePrevious row versionsQuery, Version Query, Transaction Query, TableUNDO_RETENTION, undo size
Flashback logsEarlier block imagesFlashback DatabaseDB_FLASHBACK_RETENTION_TARGET
Recycle binRenamed dropped objectsFlashback DropFree tablespace space
Flashback archiveLong-term row historyFlashback Data ArchiveRetention clause in years or days
Data sources behind Oracle Flashback features

Oracle Flashback features and their scope

Each Flashback feature targets a different granularity of error, from a single query to the whole database. Choosing the narrowest feature that fixes a problem keeps the blast radius small and avoids discarding valid work done by other users.

FeatureGranularityTypical syntaxEffect
Flashback QueryQuerySELECT ... AS OF TIMESTAMPRead-only view of past data
Flashback Version QueryRow historyVERSIONS BETWEEN SCNLists every version in a window
Flashback Transaction QueryTransactionFLASHBACK_TRANSACTION_QUERY viewShows undo SQL for a transaction
Flashback TableTableFLASHBACK TABLE ... TO TIMESTAMPRewinds rows in place
Flashback DropDropped tableFLASHBACK TABLE ... TO BEFORE DROPRestores from recycle bin
Flashback DatabaseWhole databaseFLASHBACK DATABASE TO SCNRewinds all datafiles
Scope of the main Flashback features

Flashback Data Archive, also called Total Recall in older releases, adds long-term history tracking for selected tables. It stores row versions in a dedicated archive for months or years, which supports auditing and historical reporting beyond normal undo retention.

Guaranteed restore points are a related mechanism. When one is created, Oracle keeps every flashback log needed to return to it, regardless of the retention target, which makes it a common safety net before upgrades and risky deployments.

Flashback compared with other recovery methods

Flashback is faster than restore-based recovery because it changes only the blocks that differ from the target point, while point-in-time recovery first restores whole datafiles and then rolls forward. It does not replace backups, because it cannot repair media failure or lost datafiles.

ApproachWorks fromSpeedProtects against media loss
Flashback DatabaseFlashback logs and redoMinutes, proportional to changeNo
Point-in-time recoveryRMAN backup and redoHours for large databasesYes
Database snapshotStorage or file-system copyFast, depends on platformOnly if stored elsewhere
Logical backupData Pump export fileSlow for large volumesYes, if kept off-site
Flashback versus related recovery approaches

In practice, Flashback and RMAN complement each other. RMAN provides the physical backup that survives disk loss, and Flashback handles the far more frequent human and application errors with much lower recovery time.

Configuring Flashback Database

Flashback Database requires the database to run in ARCHIVELOG mode with a configured fast recovery area. The administrator sets DB_RECOVERY_FILE_DEST and DB_RECOVERY_FILE_DEST_SIZE, chooses a retention target in minutes, and runs ALTER DATABASE FLASHBACK ON.

  • DB_FLASHBACK_RETENTION_TARGET defaults to 1,440 minutes, or one day; it is a target, not a guarantee.
  • Fast recovery area sizing must cover flashback logs, archived redo and RMAN backups together.
  • Flashback log volume tracks the block change rate, so write-heavy systems need noticeably more space.
  • The V$FLASHBACK_DATABASE_LOG view shows the oldest SCN that can currently be reached.

After a Flashback Database operation, the database must be opened with RESETLOGS, which starts a new incarnation. Alternatively, it can first be opened read-only to verify that the chosen point is correct before committing to it.

Limitations and common mistakes

Most Flashback failures come from retention that is shorter than expected or from operations that Flashback cannot reverse. Knowing these limits in advance prevents false confidence during an incident.

SymptomCausePrevention
ORA-01555 snapshot too oldUndo overwritten before the queryLarger undo, retention guarantee
Flashback Table refusedRow movement disabledALTER TABLE ... ENABLE ROW MOVEMENT
Target SCN not reachableFlashback logs aged outGuaranteed restore point
Dropped table missingRecycle bin purged or bypassedAvoid DROP ... PURGE in scripts
Typical problems and how to avoid them

Flashback Table cannot cross DDL changes such as altered columns, and Flashback Database cannot undo a shrunk datafile in some releases. Rewinding the whole database also discards all later transactions, so teams often rewind a standby or clone instead and copy back only the affected rows.

A non-technical view

Oracle Flashback works like the undo history of a word processor, but for a company database. When someone deletes the wrong customer records or runs a faulty update, the database can show or bring back the data as it looked a few minutes or hours earlier.

The key point is that it is quick and targeted. Instead of reloading a full backup, which can take hours, Flashback rewinds only what changed. It still does not replace backups, because it cannot help if the disks themselves are lost.

A concrete example

An online retailer runs an Oracle database of about 4 TB with Flashback Database enabled and a retention target of 24 hours. Before a quarterly pricing release, the database team creates a guaranteed restore point named before_pricing.

During the release, a migration script applies a discount formula to all 1.2 million products instead of one category. The team first uses Flashback Version Query to confirm when the incorrect update happened, then runs Flashback Table on the products table to the SCN just before the script.

The table is back in about six minutes, and orders placed in other tables remain untouched. A full restore from RMAN backup would have taken an estimated five hours. After the release is verified, the team drops the restore point to free space in the fast recovery area.