Run a Consistent Export with expdp FLASHBACK_TIME
Run a Consistent Export with expdp FLASHBACK_TIME
Purpose
A schema export reads many tables over a span of time, and for schemas where rows in one table reference rows in another, you usually want every table in the dump to reflect the same moment. Community Data Pump documentation puts it directly: expdp exports are by default only consistent on a per-table basis, and if you want all tables in the export to be consistent to the same point in time, you use FLASHBACK_SCN or FLASHBACK_TIME. The failure you are guarding against is a dump whose tables disagree with each other, which tends to surface only when the import runs and constraints or downstream loads expose the mismatch.
FLASHBACK_TIME is the timestamp-based way to do that. Oracle's 19c Database Utilities guide says the parameter finds the system change number (SCN) that most closely matches the specified time, that this SCN is used to enable the flashback query capability, and that the export is performed with data that is consistent up to that SCN. The same guide documents a compact form, FLASHBACK_TIME=systimestamp, which it describes as initiating a consistent export based on the current system time.
The alternative is FLASHBACK_SCN, which takes an SCN directly, so no timestamp-to-SCN lookup is involved. The two parameters are mutually exclusive: Oracle's documentation lists each as a restriction of the other.
Code
1# Form 1: pin the export to the moment the job starts (most common form)
2expdp userid=system/password \
3 DIRECTORY=dpump_dir \
4 DUMPFILE=myschema_%U.dmp \
5 LOGFILE=myschema_export.log \
6 SCHEMAS=myschema \
7 FLASHBACK_TIME=SYSTIMESTAMP
8
9# Form 2: explicit timestamp — escaping of quotes and parentheses depends on your shell
10expdp userid=system/password \
11 DIRECTORY=dpump_dir \
12 DUMPFILE=myschema_%U.dmp \
13 LOGFILE=myschema_export.log \
14 SCHEMAS=myschema \
15 FLASHBACK_TIME=\"TO_TIMESTAMP\(\'2026-07-10 02:00:00\',\'YYYY-MM-DD HH24:MI:SS\'\)\"
16
17# Form 3: parameter file avoids shell-quoting issues entirely
18# Contents of export.par:
19# DIRECTORY=dpump_dir
20# DUMPFILE=myschema_%U.dmp
21# LOGFILE=myschema_export.log
22# SCHEMAS=myschema
23# FLASHBACK_TIME="TO_TIMESTAMP('2026-07-10 02:00:00','YYYY-MM-DD HH24:MI:SS')"
24expdp userid=system/password PARFILE=export.par
1-- Capture the current SCN before the job if you want to use FLASHBACK_SCN instead
2SELECT CURRENT_SCN, SYSTIMESTAMP FROM v$database;
3
4-- Check the configured undo retention period
5SHOW PARAMETER undo_retention
6
7-- Free space in the active undo tablespace
8SELECT tablespace_name,
9 ROUND(SUM(bytes) / 1024 / 1024, 0) AS free_mb
10FROM dba_free_space
11WHERE tablespace_name IN (SELECT value
12 FROM v$parameter
13 WHERE name = 'undo_tablespace')
14GROUP BY tablespace_name;
15
16-- Recent undo behaviour: look for ORA-01555 incidents and query length
17SELECT TO_CHAR(begin_time, 'YYYY-MM-DD HH24:MI') AS period_start,
18 undoblks,
19 txncount,
20 maxquerylen,
21 ssolderrcnt
22FROM v$undostat
23ORDER BY begin_time DESC
24FETCH FIRST 12 ROWS ONLY;
Code Breakdown
Form 1: FLASHBACK_TIME=SYSTIMESTAMP
This is the simplest form for scheduled exports. There is no timestamp to calculate in the calling script, and the consistency point is the current system time rather than a hardcoded value that can go stale if a cron job fires late. Oracle documents this setting as initiating a consistent export based on current system time.
Form 2: Explicit TO_TIMESTAMP
Specifying a precise timestamp is appropriate when the export must align with an external event, such as a known application quiesce window or a timestamp recorded by an application-level procedure. Oracle documents the syntax as FLASHBACK_TIME="TO_TIMESTAMP(time-value)". Because the value is enclosed in quotation marks, and because the quoting rules of the operating system shell vary, the escaped one-liner above is shell-specific. Oracle's own advice for this form is to use a parameter file, which is Form 3.
Form 3: Parameter file
The Oracle documentation states: "Because the TO_TIMESTAMP value is enclosed in quotation marks, it is best to put this parameter in a parameter file." Its example places FLASHBACK_TIME="TO_TIMESTAMP('27-10-2012 13:16:00', 'DD-MM-YYYY HH24:MI:SS')" in a file and runs expdp hr PARFILE=flashback.par. The same layout works for the example here. Keeping a canonical export.par next to the cron entry makes the exact parameters easy to review during an audit.
SQL: capturing CURRENT_SCN
SELECT CURRENT_SCN FROM V$DATABASE returns the current SCN when the query runs. Recording that number and passing it as FLASHBACK_SCN=<number> removes the timestamp-to-SCN lookup, since the SCN is given to Data Pump directly. It also leaves you with a number you can write to a job log and refer to later when comparing or re-creating an export.
SQL: undo health checks
The undo queries serve two purposes. DBA_FREE_SPACE filtered to the undo tablespace shows how much space is free there. V$UNDOSTAT keeps statistics for 10-minute intervals, and the 19c Database Reference describes the relevant columns: MAXQUERYLEN is the length of the longest query, in seconds, executed during the period, which Oracle says you can use to estimate a proper UNDO_RETENTION setting. SSOLDERRCNT is the number of times ORA-01555 occurred, which Oracle says you can use to decide whether UNDO_RETENTION is set properly given the size of the undo tablespace. UNDOBLKS is the number of undo blocks consumed, which Oracle says helps estimate the undo tablespace size a workload needs.
Key Points
- The timestamp is converted to an SCN. Oracle's FLASHBACK_TIME documentation says the parameter finds the SCN that most closely matches the specified time. The related SQL function
TIMESTAMP_TO_SCNis documented as returning an approximate SCN, and its companionSCN_TO_TIMESTAMPdocuments a usual precision of 3 seconds.FLASHBACK_SCNskips the lookup and uses the exact SCN you supply. - Undo must still hold the data at the flashback point. Flashback query reads data as of the chosen SCN, so the undo needed to reconstruct it has to still exist when the export reaches each table. Community documentation notes you can make exports consistent to an earlier point as long as enough undo space exists.
- UNDO_RETENTION is a low threshold, honoured only if space allows. Oracle describes it as specifying, in seconds, the low threshold value of undo retention, and says it is honoured only if the current undo tablespace has enough space. If an active transaction needs undo space and none is free, the system starts reusing unexpired undo space, which can cause some queries to fail with a "snapshot too old" message.
- FLASHBACK_TIME and FLASHBACK_SCN are mutually exclusive. Oracle lists each as a restriction of the other, so choose one.
- Scope is flashback query only. Oracle states that these parameters pertain only to the flashback query capability, and are not applicable to Flashback Database, Flashback Drop, or Flashback Data Archive.
Insights and Best Practices
Prefer FLASHBACK_SCN when you need a recorded, exact consistency point
A scheduled export that needs a record of its consistency point can capture the SCN with SELECT CURRENT_SCN FROM V$DATABASE before calling expdp, write that number to the job log, and pass it as FLASHBACK_SCN. If a question arises later about what a particular export contains, a recorded SCN is a precise answer, while a timestamp has to be converted to an SCN that Oracle describes as the closest match.
Check undo configuration against your export duration
A long export asks flashback query to reconstruct data as of the flashback point for the whole run. Use MAXQUERYLEN in V$UNDOSTAT, which Oracle documents as a guide for estimating UNDO_RETENTION, to see how long queries on your system run, and compare it with how long your export takes. Remember that UNDO_RETENTION is honoured only if the undo tablespace has enough space, so check free space in the undo tablespace as well. Auto-extend with a sensible maximum datafile size is a common way to give undo room to grow without consuming all available disk, but size it against your own workload.
Review V$UNDOSTAT before introducing a new export schedule
Before making flashback exports part of a production cron, run the V$UNDOSTAT query for the planned export window over several recent days. Because the view keeps 576 rows spanning a four-day cycle, older history is not retained, so look at it soon after a representative period. High UNDOBLKS values during your planned window show heavy undo consumption at exactly the time the export needs older undo still available. Consider scheduling the export for a quieter period or increasing undo space.
Validate with a small trial before the first full-schema run
Before committing a full-schema flashback export to a cron schedule, run a small TABLES= export with the same FLASHBACK_TIME setting against the two or three largest, most active tables. Check the log for ORA-01555 and confirm the dump completes cleanly. Discovering a snapshot-too-old failure late in a long run costs more than a short trial against a hot table.
Use a parameter file for every scheduled job
Oracle's own recommendation for an explicit FLASHBACK_TIME value is a parameter file, because the value contains quotation marks. A parameter file also keeps the argument readable and reviewable on disk, independent of shell differences between environments. Treat export.par as a deployable artefact alongside the cron entry.
When to Run This
- Overnight schema exports of multi-table schemas where referential integrity must hold after import.
- Exports that feed a downstream data warehouse, where a consistent snapshot at a known time is required for correct incremental loads.
- Pre-migration safety exports before a schema change, where the dump must be importable back to a defined state if the migration fails.
- Cross-schema exports where two schemas share data through database links or synonyms that reference each other.
- Any export where the import will run with
CONSTRAINTS=yand foreign key violations would indicate an inconsistent source.
Troubleshooting Common Issues
ORA-01555: snapshot too old is the primary failure mode to watch for. The V$UNDOSTAT reference documents SSOLDERRCNT as the count of ORA-01555 occurrences and states that increasing UNDO_RETENTION can reduce them. If the undo tablespace is short of space, remember that Oracle says UNDO_RETENTION is honoured only if the undo tablespace has enough space, so adding space or enabling auto-extend may be needed in addition. Re-running the export with a more recent flashback point shortens how far back undo has to reach.
ORA-08180: no snapshot found based on specified time is documented in Oracle error help with the cause "Could not match the time to an SCN from the mapping table" and the action "try using a larger time." The related SQL reference notes that the association between an SCN and a timestamp is remembered for a limited period, and that an error is returned if the timestamp is too old. If you hit this error with an old timestamp, a FLASHBACK_SCN value you captured at the time avoids the lookup, or you can specify a more recent time.
Mutually exclusive parameters. If you pass both FLASHBACK_TIME and FLASHBACK_SCN, you are outside the documented rules, since Oracle lists each as a restriction of the other. Keep one of them in the parameter file and remove the other.
References
- Oracle Data Pump Export Utility, Database Utilities 19c — FLASHBACK_TIME and FLASHBACK_SCN reference: the SCN that most closely matches the time, the systimestamp form, the parameter file recommendation, and mutual exclusivity.
- SCN_TO_TIMESTAMP, SQL Language Reference 19c — States the usual precision of the result is 3 seconds and that the SCN-timestamp association is remembered for a limited period.
- TIMESTAMP_TO_SCN, SQL Language Reference 19c — Describes the function as returning the approximate SCN for a timestamp and an error if the timestamp is too old.
- UNDO_RETENTION, Database Reference 19c — The low threshold of undo retention in seconds, honoured only if the undo tablespace has enough space.
- V$UNDOSTAT, Database Reference 19c — 10-minute interval statistics, 576 rows over a four-day cycle, and the MAXQUERYLEN, SSOLDERRCNT, and UNDOBLKS columns.
- ORA-08180, Oracle Error Help — Cause: could not match the time to an SCN from the mapping table; action: try using a larger time.
- Oracle Data Pump (expdp, impdp), oracle-base.com — States that expdp exports are by default consistent only per table, and that FLASHBACK_SCN or FLASHBACK_TIME gives a consistent point across tables.
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