Oracle exp: Export Database with FLASHBACK_TIME
Export an Oracle Database from a Point in Time Using FLASHBACK_TIME
The Oracle exp utility supports a FLASHBACK_TIME parameter that lets a database administrator export a full database with all data consistent to a single point in time. This is critical for large, active databases where export duration may span minutes or hours and data must not drift between tables.
Purpose
When you run a standard Oracle export on a live database, different tables may be captured at slightly different moments. This can produce an inconsistent dump file where related tables are out of sync. The FLASHBACK_TIME parameter solves this by anchoring all exported data to one specific timestamp — Oracle translates that timestamp into a System Change Number (SCN) and uses Flashback Query internally to read data as it was at that exact moment.
This technique is the modern replacement for the older CONSISTENT=Y parameter of the legacy exp tool.
Breakdown of Code
Method 1 — Command-Line Export with FLASHBACK_TIME
1exp / file=full_scr9.dmp log=full_scr9.log flashback_time=TO_TIMESTAMP('10-09-2006 09:00:00', 'DD-MM-YYYY HH24:MI:SS')
| Part | What It Does |
|---|---|
exp / | Runs the Oracle export utility using OS authentication (no password required when run as oracle OS user) |
file=full_scr9.dmp | Sets the output dump file name to full_scr9.dmp |
log=full_scr9.log | Writes all export activity and messages to full_scr9.log |
flashback_time=TO_TIMESTAMP(...) | Converts the text string '10-09-2006 09:00:00' using format DD-MM-YYYY HH24:MI:SS into an Oracle TIMESTAMP, which exp uses to find the nearest SCN |
The TO_TIMESTAMP function is standard Oracle SQL that parses a string into a proper timestamp value using a named format model.
Method 2 — Export Using a Parameter File (parfile)
1exp / parfile=full_scr9.par
Contents of full_scr9.par:
1userid=system/******
2file=full_scr9.dmp
3log=full_scr9.log
4flashback_time='2006-09-13 12:00:00'
| Part | What It Does |
|---|---|
exp / parfile=full_scr9.par | Tells exp to read all parameters from the external file full_scr9.par instead of the command line |
userid=system/****** | Sets the connecting user; the password is masked here for security |
file=full_scr9.dmp | Destination dump file |
log=full_scr9.log | Destination log file |
flashback_time='2006-09-13 12:00:00' | The plain timestamp string used inside a parfile; exp accepts this simplified format directly within a parameter file |
Using a parfile keeps credentials out of shell history and makes the command repeatable and scriptable.
Key Points
- FLASHBACK_TIME vs FLASHBACK_SCN —
FLASHBACK_SCNnames the SCN directly;FLASHBACK_TIMElets Export find the SCN that most closely matches a timestamp. - SCN resolution — Oracle does not use the timestamp directly. It finds the SCN that most closely matches your given timestamp, then performs a Flashback Query from that SCN.
- Undo dependency — The flashback export relies on undo data still being available in the UNDO tablespace. If undo data for the target time has been recycled, the export will fail.
- OS authentication (
/) — Usingexp /connects via OS-level authentication. This requires the OS user running the command to be in thedbagroup and is only valid locally on the database server. - Timestamp format — The value can be any format that
DBMS_FLASHBACK.ENABLE_AT_TIMEaccepts; the plain quoted string'YYYY-MM-DD HH24:MI:SS'is also accepted for backward compatibility. - Legacy tool note — The
exputility is the original export tool (pre-Data Pump). Original Export is desupported for general use as of Oracle Database 11g; its only supported use in 11g and later is backward migration of XMLType data to 10.2 or earlier. Useexpdp/impdpinstead.
Insights and Explanations
Why Point-in-Time Export Matters
On a busy production database, rows in Table A may be committed while Table B is still mid-transaction during an export run. Without a flashback anchor, the resulting dump represents no single real state of the database — a serious problem for consistent restores, audits, or migrations.
TO_TIMESTAMP Format Model
The format string 'DD-MM-YYYY HH24:MI:SS' is an Oracle NLS format mask:
DD— two-digit dayMM— two-digit monthYYYY— four-digit yearHH24— hour in 24-hour formatMI— minutesSS— seconds
This must exactly match the literal string passed as the first argument or Oracle will throw an ORA-01858 or similar date format error.
parfile vs Command-Line Syntax Difference
Both forms are valid on the command line and in a parfile: FLASHBACK_TIME accepts any format that DBMS_FLASHBACK.ENABLE_AT_TIME accepts, including TO_TIMESTAMP(...), and the plain quoted string is kept for backward compatibility. Shell quoting is often easier inside a parfile.
Moving to Data Pump (Modern Alternative)
For Oracle 10g and newer, Oracle recommends replacing exp with expdp (Data Pump Export). The equivalent Data Pump command would be:
1expdp system/****** full=y dumpfile=full_scr9.dmp logfile=full_scr9.log \
2 flashback_time=\"to_timestamp\(\'2006-09-13 12:00:00\', \'YYYY-MM-DD HH24:MI:SS\'\)\"
Or more simply using systimestamp for the current moment: flashback_time=systimestamp.
Security Best Practice
The userid=system/****** line in the parfile means the plain-text password sits in a file on disk. Always restrict file permissions on parfiles to the oracle OS user only (chmod 600 full_scr9.par) and avoid placing them in world-readable directories.
References
- Oracle Original Export Utility — Oracle 19c Documentation — Official Oracle 19c documentation covering all
expparameters includingFLASHBACK_TIMEandFLASHBACK_SCN - Oracle Data Pump Export — FLASHBACK_TIME Parameter — Oracle 19c Data Pump
expdpdocumentation explaining howFLASHBACK_TIMEresolves to an SCN - Oracle Data Pump — FLASHBACK_SCN and FLASHBACK_TIME (Oracle Forums) — Community discussion comparing
CONSISTENT=Y(legacyexp) withFLASHBACK_TIMEin Data Pump - Make a Time-Consistent Export Dump Using expdp — AMIS Technology Blog — Practical tutorial on using
flashback_timewith bothexpdpand parfiles - Oracle Data Pump (expdp, impdp) in Oracle 10g/11g/12c — oracle-base.com — Comprehensive reference on Oracle Data Pump including flashback parameter usage and escaped command-line syntax
- Export Tables with the exp Command and a parfile — Niklas Ottosson Blog — Step-by-step example of using
expwith an external parameter file - Consistent Export Using expdp with FLASHBACK_SCN — Steve Cao Blog — Explains per-table vs. full-export consistency and when
FLASHBACK_SCN/FLASHBACK_TIMEis required - FLASHBACK Parameter in DATAPUMP (EXPDP) — dbaclass.com — DBA-focused guide explaining undo dependency for flashback exports and failure scenarios
- Oracle Export Utility — Oracle 9.2 Help Center (exp PARFILE syntax) — Legacy Oracle documentation showing
PARFILEoverride behavior and parameter file syntax rules - FLASHBACK_TIME in expdp — Oracle Forums — Community discussion confirming
FLASHBACK_TIMEandFLASHBACK_SCNare mutually exclusive
Posts in this series
- Oracle Flashback: Enable with Shutdown, Mount, ALTER
- DB_FLASHBACK_RETENTION_TARGET: Set Oracle Flashback Window
- Oracle Fast Recovery Area: Set db_recovery_file_dest
- Oracle: Get Current SCN with DBMS_FLASHBACK
- Oracle exp: Export Database with FLASHBACK_TIME
- Oracle Flashback Query: Copy Historical Data to a Table
- Oracle: Disable Flashback with DBMS_FLASHBACK.DISABLE
- Oracle DBMS_FLASHBACK.ENABLE_AT_TIME: Session Flashback
- Run a Consistent Export with expdp FLASHBACK_TIME
- Manage the Recycle Bin with DBA_RECYCLEBIN