Oracle Database Export with Date Stamping: A Solution

By LKBrwnDBA | Created on 2025-12-16 11:33:36

Written with a informative tone 📝 | Model: keyless-gpt-4o-mini

0:00 / 0:00

Exporting databases can be a complex task, especially when it comes to managing different versions and files. In this guide, we will explore how to export an Oracle database while incorporating date stamping into the file names.

The Problem

Oracle's built-in export tool does not allow for direct integration of date stamps into the filename. This can make it difficult to manage multiple exports and keep track of which files are associated with specific dates.

The Solution

LKBrwnDBA, a knowledgeable member of Oracle forums, provided a work-around for this issue. They created a PL/SQL procedure that opens a data pump job, sets the export parameters, and adds the date stamp to the filename.

Creating the Procedure

To create the procedure, follow these steps:

  1. Select the database from the EM (Enterprise Manager) console.
  2. Go to Maintenance > Export to Export files.
  3. Select any/all export options.
  4. At the end, before submitting, click on "Show PL/SQL".
  5. Copy and paste into an editor.
  6. Edit the procedure to add the date stamp and save it.
  7. Schedule your procedure!

Example Procedure Code

The following is an example of what the modified procedure might look like:

declare
h1   NUMBER;
dt    VARCHAR2(12);
begin
SELECT TO_CHAR(SYSDATE,'YYYYMMDD') INTO dt FROM DUAL;
begin
h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'DP_EXPORT_SSU_MONTH_END', version => 'COMPATIBLE');
end;
begin
dbms_datapump.set_parallel(handle => h1, degree => 1);
end;
begin
dbms_datapump.add_file(handle => h1, filename => 'EXPSSU'||dt||'.LOG', directory => 'EXP_DIR', filetype => 3);
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0);
end;
begin
dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''SSU'')');
end;
begin
dbms_datapump.add_file(handle => h1, filename => 'EXPSSU'||dt||'.DMP', directory => 'EXP_DIR', filetype => 1);
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
end;
begin
dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS');
end;
begin
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
end;
begin
dbms_datapump.detach(handle => h1);
end;
end;

Implementing the Solution

To implement this solution, follow these steps:

  1. Create a new job with type 'SQL Script'.
  2. Paste the modified procedure code into the editor.
  3. Edit the procedure to add the date stamp and save it.
  4. Schedule your procedure!

Conclusion

By following these steps, you can create a PL/SQL procedure that opens a data pump job, sets the export parameters, and adds the date stamp to the filename. This will make it easier to manage multiple exports and keep track of which files are associated with specific dates.

Share Your Experience!

Have you encountered any issues while implementing this solution? Share your experience in the comments section below!

Sources:
- [How to Append Current Date to Export Dump file name | Tek-Tips] (https://www.tek-tips.com/threads/how-to-append-current-date-to-export-dump-file-name.1521583/)
- [Why does'nt text-align:justify work? Help | Tek-Tips] (https://www.tek-tips.com/threads/why-doesnt-text-align-justify-work-help.1690560/)
- [Coverage Paths | Tek-Tips] (https://www.tek-tips.com/threads/coverage-paths.1632312/)
- [Query a Registry Key | Tek-Tips] (https://www.tek-tips.com/threads/query-a-registry-key.860209/)
- [2 divs parallel w/o negative top: value | Tek-Tips] (https://www.tek-tips.com/threads/2-divs-parallel-w-o-negative-top-value.1254101/)
- [Moving Aplications to a new screen in C# | Tek-Tips] (https://www.tek-tips.com/threads/moving-aplications-to-a-new-screen-in-c.1416749/)
- [Microsoft VBScript runtime error '800a01b6' | Tek-Tips] (https://www.tek-tips.com/threads/microsoft-vbscript-runtime-error-800a01b6.419805/)
- [HTA new window with Parameters | Tek-Tips] (https://www.tek-tips.com/threads/hta-new-window-with-parameters.1295803/)
- [Error: Only content controls are allowed directly in a ... - Tek-Tips] (https://www.tek-tips.com/threads/error-only-content-controls-are-allowed-directly-in-a-content-page.1504551/)
- [bulleted list does not align the text on the 2nd line | Tek-Tips] (https://www.tek-tips.com/threads/bulleted-list-does-not-align-the-text-on-the-2nd-line.1640644/)

Related Posts