

- Ivan Luminaria/
- Database Strategy/
- Oracle/
- The Tuesday morning meeting: Oracle Flashback and logical recovery without downtime/
The Tuesday morning meeting: Oracle Flashback and logical recovery without downtime
The Tuesday morning meeting #
The report came in during a weekly Teams meeting — not as a monitoring alert, not as an urgent ticket. One of the area managers shared their screen and said, with a tone more puzzled than alarmed: “Yesterday’s numbers don’t add up. And neither do the day before’s.”
The executive dashboard of a large Italian insurance group — the one that feeds daily operational decisions on premiums and claims every morning — was showing inconsistent data. Not a crash, not a blank page. The data was there, but it was wrong. Or rather: it was incomplete, and nobody had received an alert because technically the system was working fine. The pipeline was running, the tables were accessible, the queries were responding. It’s just that some rows had disappeared roughly forty-eight hours earlier.
Thirty minutes of meeting to gather observations from colleagues, narrow down the problem’s time window, and establish that this wasn’t a service outage but a silent logical error. Then the inevitable question: how do you recover that data?
The answer, in that context, was not “restore from backup.”
Why a full backup restore wasn’t the first move #
A restore from backup on a table of roughly 500 GB and 2 billion rows is not something you do in an hour. It requires a maintenance window, a staging environment for selective restoration, dependency management with other tables, and almost certainly a service interruption for users. In an insurance context where the dashboard feeds daily decisions on active portfolios, that has a real cost.
Oracle, however, has offered for years a suite of features that allows something far more surgical: going back in time at the level of a single query, a table, or even the entire database, leveraging data the engine already keeps for other purposes — undo segments and flashback logs. Collectively, these technologies are called Oracle Flashback [1].
The principle is straightforward: Oracle maintains previous versions of data blocks to handle read consistency (MVCC) and transaction rollback. Flashback features exploit this infrastructure to enable targeted recovery operations, without touching backups.
Flashback Query: fifteen minutes to find the needle #
The first thing to do was figure out exactly what was missing. Flashback Query lets you run a SELECT as if the database were in a previous state, by specifying a timestamp or an SCN (System Change Number) [2].
The SCN is an internal Oracle counter that advances monotonically with each commit: it identifies a precise point in the database’s history. Every row has an SCN associated with its last modification. Flashback Query uses undo segments to reconstruct the version of a row at a past SCN.
The first query was a simple count, to verify how many rows existed two days ago compared to today:
-- Row count as of 48 hours ago
SELECT COUNT(*)
FROM DASHBOARD_DATA.DAILY_SALES_METRICS
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' DAY);
The result confirmed the hypothesis: the table had contained roughly 340,000 more rows than its current state. Something had removed them, and the system hadn’t generated an alert because the removal had happened through an apparently normal transaction.
The second query isolated the missing rows for a specific date:
-- Rows present yesterday for a specific sales date
SELECT *
FROM DASHBOARD_DATA.DAILY_SALES_METRICS
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' DAY)
WHERE sales_date = TO_DATE('2024-11-22', 'YYYY-MM-DD');
Fifteen minutes of analysis. The rows were there, they had been deleted, and the deletion pattern pointed to a misconfigured batch job that had run a DELETE with a broader condition than intended. No application error, no rollback: the transaction had completed successfully, but it had done more than it should have.
The recovery was equally straightforward: an INSERT ... SELECT ... AS OF TIMESTAMP to reinsert the missing rows from the historical version of the table. Five minutes, no service interruption, no maintenance window.
-- Reinserting accidentally deleted rows
INSERT INTO DASHBOARD_DATA.DAILY_SALES_METRICS
SELECT *
FROM DASHBOARD_DATA.DAILY_SALES_METRICS
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' DAY)
WHERE sales_date BETWEEN TO_DATE('2024-11-20', 'YYYY-MM-DD')
AND TO_DATE('2024-11-22', 'YYYY-MM-DD')
AND metric_id NOT IN (
SELECT metric_id FROM DASHBOARD_DATA.DAILY_SALES_METRICS
);
For Flashback Query to work, the undo data must still be available — meaning the UNDO_RETENTION parameter must be configured for a sufficient period and the undo segments must not have been overwritten due to space pressure. In this case, the system was configured with a 24-hour retention, enough to cover the forty-eight-hour window thanks to the combination with flashback logs.
Flashback Table and Flashback Drop: when you need something more #
Flashback Query is the right tool when you know what you’re looking for and want to recover specific rows. But there are scenarios where a different approach is needed.
Restoring an entire table #
FLASHBACK TABLE brings an entire table — data and structure — back to a previous point in time [3]. It’s useful when the corruption is widespread and it’s not worth identifying row by row what needs recovering.
-- Restoring a table to one hour ago
FLASHBACK TABLE DASHBOARD_DATA.DAILY_SALES_METRICS
TO TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' HOUR);
Two requirements worth keeping in mind:
ROW MOVEMENT must be enabled on the table. During the flashback, Oracle may need to physically move rows (the ROWID changes), and this requires the table to explicitly allow it:
ALTER TABLE DASHBOARD_DATA.DAILY_SALES_METRICS ENABLE ROW MOVEMENT;
UNDO retention must cover the point in time you want to go back to. If the undo segments have been overwritten, the operation fails with ORA-01555: snapshot too old.
Unlike a restore from backup, FLASHBACK TABLE doesn’t require bringing the database into mount mode, doesn’t interrupt active sessions on other tables, and doesn’t require a maintenance window. The service stays available.
Recovering a dropped table #
FLASHBACK DROP is the most dramatic case and, paradoxically, one of the simplest to handle [3]. When you run a DROP TABLE without PURGE, Oracle doesn’t physically delete the table: it moves it to the Recycle Bin, a logical area of tablespace where dropped objects remain until the space is needed for other purposes.
-- Recovering an accidentally dropped table
FLASHBACK TABLE DASHBOARD_DATA.STAGING_METRICS TO BEFORE DROP;
To see what’s in the Recycle Bin:
SELECT object_name, original_name, droptime, space
FROM recyclebin
ORDER BY droptime DESC;
There are two limits: if the table was dropped with PURGE, or if the Recycle Bin has been emptied (PURGE RECYCLEBIN), there’s nothing to recover. And if tablespace is under pressure, Oracle can automatically reuse Recycle Bin space without warning.
Flashback Database: the serious case #
The three previous features operate at the object or row level. FLASHBACK DATABASE is a different category entirely: it brings the entire database back to a previous point in time, as if you pressed a global “undo” button [4].
It’s used in scenarios where the error is pervasive: an application patch that corrupted data across dozens of tables, a schema update gone wrong, a logical error that propagated through procedures and triggers before anyone noticed.
The requirements are more demanding than the other features:
- Flashback Logging must be enabled (
ALTER DATABASE FLASHBACK ON) - A Fast Recovery Area (FRA) must be configured with sufficient space
- The
DB_FLASHBACK_RETENTION_TARGETparameter defines how many minutes the database retains flashback logs (in the insurance group’s system it was set to 4320 minutes, i.e., 3 days)
The recovery workflow requires bringing the database into mount mode:
-- Flashback Database workflow
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIMESTAMP
TO_TIMESTAMP('2024-11-22 08:00:00', 'YYYY-MM-DD HH24:MI:SS');
ALTER DATABASE OPEN RESETLOGS;
RESETLOGS is mandatory: after a Flashback Database, the redo logs are reset because the database’s history has been rewritten. This means that backups taken before the RESETLOGS are no longer directly applicable for incremental recovery — a full backup must be taken immediately after the operation.
The difference compared to a traditional restore is time: a Flashback Database on a system with a well-sized FRA can complete in minutes rather than hours, because it works on flashback logs (modified blocks) rather than having to restore the entire physical database structure.
The limits you can’t ignore #
Oracle Flashback is not a backup replacement. It’s a complement for logical errors within a defined time window. Three practical aspects to keep in mind:
Dependency on UNDO retention. Flashback Query and Flashback Table depend on the availability of undo data. If the UNDO tablespace is under pressure, Oracle can overwrite undo data before the configured retention expires. The UNDO_RETENTION parameter is a target, not an absolute guarantee — unless you enable RETENTION GUARANTEE on the UNDO tablespace, which prevents overwriting even at the cost of failing transactions that need space.
Space impact. The flashback logs for FLASHBACK DATABASE consume space in the FRA. With DB_FLASHBACK_RETENTION_TARGET at 3 days on a database with heavy workload, the FRA can grow quickly. Monitoring FRA space is part of routine operations, not an occasional activity [5].
-- FRA space monitoring
SELECT name, space_limit/1024/1024/1024 AS limit_gb,
space_used/1024/1024/1024 AS used_gb,
space_reclaimable/1024/1024/1024 AS reclaimable_gb
FROM v$recovery_file_dest;
Physical errors and media failure. Flashback doesn’t help with physical block corruption, datafile loss, or hardware failure. For those scenarios you need traditional backups, Data Guard, or both. The Flashback suite covers the category of logical errors — which, statistically, are the most frequent cause of data loss in production, but not the only one.
What stays after the meeting #
The data was recovered. The dashboard was reliable again by midday, without any user perceiving an interruption. The batch job responsible for the deletion was corrected and added to the change management verification checklist.
The point worth emphasizing isn’t the speed of the recovery — fifty minutes from the start of the meeting to a restored dashboard — but the nature of the tool. Flashback Query didn’t require stopping anything. It didn’t require involving the infrastructure team for a restore. It didn’t require communicating with users.
It required knowing it existed and how it worked.
In many Oracle environments, Flashback features are enabled by default or with minimal configuration, but they’re never used because they’re not part of the daily operational playbook. They end up in manuals, not in runbooks. And when a fast recovery is needed, the tendency is to jump straight to backup — which is the right answer for many scenarios, but not all of them.
Investing a few hours to understand the difference between FLASHBACK TABLE and an RMAN restore, to test FLASHBACK DATABASE in a pre-production environment, to correctly configure UNDO_RETENTION and the FRA: that’s the kind of preparatory work that produces no visible results until it’s needed. And when it’s needed, it produces very visible results.
Official sources #
- Oracle Database — Using Oracle Flashback Technology — overview of Flashback features, SCN, undo segments, general architecture.
- Oracle Database SQL Language Reference 19c — SELECT (Flashback Queries) —
AS OF TIMESTAMPandAS OF SCNsyntax, Flashback Version Query and Flashback Transaction Query clauses. - Oracle Database SQL Language Reference 19c — FLASHBACK TABLE —
FLASHBACK TABLE ... TO TIMESTAMP,TO BEFORE DROPsyntax, ROW MOVEMENT requirements, Recycle Bin. - Oracle Database Backup and Recovery User’s Guide 19c — Performing Flashback Database and Database Point-in-Time Recovery —
FLASHBACK DATABASEworkflow, FRA and Flashback Logging requirements,OPEN RESETLOGS. - Oracle Database Reference 19c — DB_FLASHBACK_RETENTION_TARGET — configuration parameter, unit (minutes), interaction with the FRA.
Glossary #
Flashback Query (Oracle) — Feature that allows running a
SELECTagainst a past state of the database, specifying a timestamp or SCN. Uses undo data without requiring a restore from backup. Useful for identifying and recovering accidentally deleted or modified rows.Flashback Table (Oracle) — Command that restores an entire table to a previous point in time, including its data. Requires
ROW MOVEMENTenabled on the table and undo data still available. Does not interrupt active sessions on other database tables.Flashback Database (Oracle) — Recovery technique that brings the entire database back to a previous point in time using flashback logs in the Fast Recovery Area. Requires
STARTUP MOUNTand closes withOPEN RESETLOGS. Faster than a full RMAN restore for pervasive logical errors.SCN (System Change Number) — Oracle’s internal counter that advances monotonically with each commit. Identifies a precise point in the database’s history. Flashback operations use the SCN as a precise temporal reference, as an alternative or complement to timestamps.
RTO (Recovery Time Objective) — Maximum acceptable downtime for a system after an error or disaster. Flashback features reduce RTO for logical errors from hours (restore from backup) to minutes, without requiring maintenance windows.
