How to Enable Oracle Database Flashback: Shutdown, Mount, and ALTER Commands


How to Enable Oracle Database Flashback: Shutdown, Mount, and ALTER Commands

Oracle Flashback Database is one of the most powerful data protection tools available to a DBA. This guide walks you through the four commands needed to turn on Oracle Flashback β€” from a clean shutdown to opening the database in flashback mode.


What Is Oracle Flashback Database?

Oracle Flashback Database lets you rewind your entire database to a previous point in time β€” without a full restore. Think of it like an "undo" button for your whole database. Instead of restoring from backup tapes, Oracle reads special flashback logs stored in the Fast Recovery Area (FRA) and rolls the database back in minutes.[^1][^2]

This is different from Flashback Query or Flashback Table, which work on individual rows or tables. Flashback Database works at the whole-database level and is the fastest alternative to a traditional Point-In-Time Recovery (PITR).[^2]


Prerequisites Before You Begin

Before running these commands, two things must be set up:[^3]

  • DB_RECOVERY_FILE_DEST β€” the path where Oracle stores flashback logs (your Fast Recovery Area)
  • DB_RECOVERY_FILE_DEST_SIZE β€” the maximum space Oracle can use for those logs

You also need the SYSDBA privilege to run all of these commands.[^4]

Check your current FRA settings first:

1SHOW PARAMETER db_recovery_file_dest;
2SHOW PARAMETER db_recovery_file_dest_size;

If not set, configure them:

1ALTER SYSTEM SET db_recovery_file_dest = '/u01/fra';
2ALTER SYSTEM SET db_recovery_file_dest_size = 20G;

The Code: Enable Flashback Database

 1-- Step 1: Cleanly shut down the running database
 2SHUTDOWN IMMEDIATE;
 3
 4-- Step 2: Start the instance but do not open the database (mount only)
 5STARTUP MOUNT;
 6
 7-- Step 3: Enable Flashback Database logging
 8ALTER DATABASE FLASHBACK ON;
 9
10-- Step 4: Open the database for normal use
11ALTER DATABASE OPEN;

Breakdown of Each Command

SHUTDOWN IMMEDIATE

This command stops all active sessions, rolls back uncommitted transactions, and closes the database cleanly. Using IMMEDIATE is preferred over ABORT because it ensures the database is in a consistent state before the next startup β€” no instance recovery is needed.[^5][^2]

Why it matters: Enabling Flashback requires the database to be in MOUNT state. You cannot go to MOUNT without first shutting down.


STARTUP MOUNT

This command starts the Oracle instance and mounts the control file, but does not open the datafiles to users. The database is alive and connected internally, but no regular user can connect.[^6]

Why MOUNT and not OPEN? In Oracle 10g and 11gR1, flashback mode can only be enabled while the database is in MOUNT state. Starting from Oracle 11gR2, you can enable or disable flashback while the database is OPEN β€” but the MOUNT method works across all versions and is the safest approach.[^7][^2]

Oracle VersionCan Enable Flashback While OPEN?
10gNo β€” must be in MOUNT state [^2]
11gR1No β€” must be in MOUNT state [^2]
11gR2 and laterYes β€” MOUNT or OPEN both work [^7]

ALTER DATABASE FLASHBACK ON

This is the core command. It tells Oracle to start writing flashback logs to the Fast Recovery Area. From this moment forward, Oracle continuously records before-images of changed data blocks so the database can be rewound to any point within the flashback retention window.[^4][^1]

Key setting to know:

1ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET = 1440; -- 1440 minutes = 24 hours

DB_FLASHBACK_RETENTION_TARGET controls how far back in time you can flash the database. Set it in minutes. The default is 1440 (24 hours).[^1]

Verify it worked:

1SELECT FLASHBACK_ON FROM V$DATABASE;

You should see YES in the output.[^8]


ALTER DATABASE OPEN

This command opens the datafiles and makes the database available to all users. After this step, the database runs normally β€” and flashback logging runs silently in the background.[^5]


Key Points and Insights

  • Space matters most. Flashback log generation is roughly equal in volume to redo log generation. Size your FRA accordingly β€” a good conservative approach is FRA size = 3 Γ— DB_FLASHBACK_RETENTION_TARGET Γ— redo generation rate.[^1]
  • Flashback is not a backup replacement. It protects against logical errors (bad batch jobs, accidental deletes), not physical media failure. Keep your RMAN backups too.[^9]
  • Guaranteed Restore Points (GRP) are even more reliable than standard flashback. When you create a GRP, Oracle guarantees those flashback logs are never deleted until you drop the GRP β€” normal flashback logs can be recycled under space pressure.[^1]
  • Performance impact is low. Oracle's block-new optimization means flashback log writes are typically less than 5% of physical write volume in most workloads.[^1]
  • Check flashback status and oldest SCN using:
1SELECT OLDEST_FLASHBACK_TIME, FLASHBACK_SIZE
2FROM V$FLASHBACK_DATABASE_LOG;

How to Use Flashback After Enabling It

Once enabled, here is how to rewind your database to a previous time:[^10]

 1-- Shut down and mount the database
 2SHUTDOWN IMMEDIATE;
 3STARTUP MOUNT;
 4
 5-- Flashback to a specific timestamp
 6FLASHBACK DATABASE TO TIMESTAMP
 7  TO_TIMESTAMP('2026-03-12 10:00:00', 'YYYY-MM-DD HH24:MI:SS');
 8
 9-- Re-open with RESETLOGS (required after flashback)
10ALTER DATABASE OPEN RESETLOGS;

How to Turn Flashback Off

1SHUTDOWN IMMEDIATE;
2STARTUP MOUNT;
3ALTER DATABASE FLASHBACK OFF;
4ALTER DATABASE OPEN;

Verify with SELECT FLASHBACK_ON FROM V$DATABASE; β€” it will return NO.[^8]


References

Posts in this series