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 Version | Can Enable Flashback While OPEN? |
|---|---|
| 10g | No β must be in MOUNT state [^2] |
| 11gR1 | No β must be in MOUNT state [^2] |
| 11gR2 and later | Yes β 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
- Oracle Official SQL Reference β FLASHBACK DATABASE Statement β Covers the full syntax, prerequisites, SCN and timestamp options, and PDB-level flashback behavior. https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/FLASHBACK-DATABASE.html[^4]
- Oracle Flashback Best Practices (Oracle Database 23ai High Availability Guide) β Official Oracle guide covering FRA sizing formulas, retention targets, Guaranteed Restore Points, and performance tuning for flashback logging. https://docs.oracle.com/en/database/oracle/oracle-database/23/haovw/oracle-flashback-best-practices.html[^1]
- How to Enable and Disable Flashback in Oracle Database β DBAClass β Practical DBA walkthrough with parameter setup, enable/disable steps, and
V$DATABASEverification queries. https://dbaclass.com/article/how-to-enable-and-disable-flashback-in-oracle-database/[^8] - Flashback Database in Oracle Database 10g β ORACLE-BASE β Tim Hall's step-by-step guide covering 10g/11g mount-state requirements and flashback-to-timestamp examples. https://oracle-base.com/articles/10g/flashback-database-10g[^2]
- Introduction to Oracle Flashback Technology Part 3 β Redgate Simple Talk β Deep-dive article on flashback database internals, FRA configuration with
DB_RECOVERY_FILE_DEST, and space sizing guidance. https://www.red-gate.com/simple-talk/databases/oracle-databases/introduction-to-oracle-flashback-technology-part-3-flashback-database/[^3] - Turning Flashback Database On and Off with Instance in Status OPEN β Uwe Hesse Blog β Explains version differences (10g vs 11gR2+) for enabling flashback and when MOUNT is and is not required. https://uhesse.com/2010/06/25/turning-flashback-database-on-off-with-instance-in-status-open/[^7]
- Important Flashback Commands β Learnomate Technologies β Quick-reference command sheet covering flashback to SCN, timestamp, and Guaranteed Restore Points. https://learnomate.org/important-flashback-commands/[^10]
- Performing Flashback and Database Point-In-Time Recovery β Oracle 19c Backup and Recovery Guide β Official Oracle documentation on performing a full Flashback Database operation with RMAN and SQL*Plus. https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/rman-performing-flashback-dbpitr.html[^9]