Oracle Data Pump: Create the DATA_PUMP_DIR Directory

Oracle Data Pump: Create the DATA_PUMP_DIR Directory

Before you can run any Oracle Data Pump export (expdp) or import (impdp) job, Oracle needs to know where to write and read dump files and log files on the server. You do this by creating a directory object inside the database that points to a real folder on the operating system.

What This Script Does

This one-line SQL command creates a database directory object named DATA_PUMP_DIR that maps to the physical path /u01/ora_backup/datapump on the server. Once created, Oracle Data Pump jobs can use this directory to store export dump files and log files.

The Code

1CREATE DIRECTORY data_pump_dir AS '/u01/ora_backup/datapump';

Breakdown of the Code

PartWhat It Means
CREATE DIRECTORYSQL command that creates a new database directory object
data_pump_dirThe name of the directory object inside the Oracle database
AS '/u01/ora_backup/datapump'The real physical folder path on the operating system (OS)

Step by step:

  1. CREATE DIRECTORY — This is a standard Oracle DDL (Data Definition Language) command. It tells the database to register a new directory object. It does not create the physical folder on the OS — you must create that folder yourself first using Linux/Unix commands (e.g., mkdir -p /u01/ora_backup/datapump).
  2. data_pump_dir — This is the logical name Oracle uses internally. Data Pump utilities (expdp, impdp) reference this name, not the physical path.
  3. AS '/u01/ora_backup/datapump' — This is the absolute path on the database server's file system. The Oracle database process must have read and write permission on this OS folder.

Purpose

The purpose of this command is to register a secure, controlled file location for Oracle Data Pump operations. Oracle Database requires a directory object to define where dump files (.dmp) and log files (.log) are stored during exports and imports. A user who is not privileged cannot run Data Pump until a DBA, or a user with CREATE ANY DIRECTORY, creates a directory object. A privileged user who names none falls back to the default DATA_PUMP_DIR, whose path may not have enough space or the right permissions.

Why Use a Custom Directory?

Oracle does install a default DATA_PUMP_DIR at database creation time, but its path is set by Oracle and can change during upgrades or patch applications. By creating your own DATA_PUMP_DIR pointing to /u01/ora_backup/datapump, you:

  • Control exactly where backup files are stored
  • Separate backup data from Oracle software directories
  • Make it easy to manage disk space for large exports
  • Follow a consistent naming convention across all your Oracle servers

Key Points

  • Run as SYSDBA or a privileged user. Only users with the CREATE ANY DIRECTORY system privilege can run this command.
  • Create the OS folder first. The physical path /u01/ora_backup/datapump must exist on the server before the directory object is useful. Use mkdir -p /u01/ora_backup/datapump and then set correct ownership with chown oracle:oinstall /u01/ora_backup/datapump.
  • Grant access to users. After creating the directory, you must grant READ and WRITE privileges to any database user who will run Data Pump jobs.
  • CREATE OR REPLACE is safer for re-runs. Use CREATE OR REPLACE DIRECTORY data_pump_dir AS '/u01/ora_backup/datapump'; if the directory object may already exist — it will update the path without an error.
  • One name, one path. A directory object maps to exactly one OS path. You can have many directory objects pointing to different paths.
  • PDB (Pluggable Database) note. In Oracle 12c Release 2 and later multitenant (CDB/PDB) environments, the default DATA_PUMP_DIR is defined as a unique path for each PDB. To see the path a PDB uses, connect to that PDB and run the DBA_DIRECTORIES query in Step 4. One write-up on 12.1.0.2 found that CREATE OR REPLACE DIRECTORY data_pump_dir inside a PDB fails with ORA-65040, and it used a separate directory name (DATA_PUMP_DIR_PDB) with the DIRECTORY= parameter instead. Test on your own release before you rely on either approach.

Full Setup Example

Here is the complete recommended setup from OS to database:

Step 1 — Create the OS directory (run as root or oracle OS user):

1mkdir -p /u01/ora_backup/datapump
2chown oracle:oinstall /u01/ora_backup/datapump
3chmod 755 /u01/ora_backup/datapump

Step 2 — Create the Oracle directory object (run in SQL*Plus as SYSDBA):

1CREATE OR REPLACE DIRECTORY data_pump_dir AS '/u01/ora_backup/datapump';

Step 3 — Grant access to a database user (example: user scott):

1GRANT READ, WRITE ON DIRECTORY data_pump_dir TO scott;

Step 4 — Verify the directory was created:

1SELECT owner, directory_name, directory_path
2FROM dba_directories
3WHERE directory_name = 'DATA_PUMP_DIR';

Step 5 — Test with a simple export:

1expdp scott/tiger DIRECTORY=data_pump_dir DUMPFILE=test_export.dmp LOGFILE=test_export.log SCHEMAS=scott

Insights and Best Practices

  • Dedicated backup volume. Mount /u01/ora_backup on a separate disk or NFS share dedicated to backups. This prevents the backup from filling the OS root filesystem.
  • Naming convention. The name DATA_PUMP_DIR is the Oracle standard default name. Using this name means you do not need to specify DIRECTORY= on every expdp/impdp command for privileged users — Oracle uses it automatically.
  • Check the path after upgrades. Oracle may redefine the DATA_PUMP_DIR path during database upgrades. Always verify the path after an upgrade with the DBA_DIRECTORIES query above.
  • Space planning. Export dump files can be very large for full exports. Monitor free space on /u01/ora_backup/datapump regularly.
  • Security. Restrict the CREATE ANY DIRECTORY privilege tightly. Oracle's Data Pump documentation says that for security reasons, DBAs must ensure that only approved users are allowed access to directory objects. Object privileges on a directory are separate from the OS permissions on the folder, so check both.

Quick Reference: Key Oracle Views

ViewPurpose
DBA_DIRECTORIESLists all directory objects, their owners, and OS paths
ALL_DIRECTORIESLists directory objects the current user can access
V$PARAMETERShows the initialization parameters currently in effect for the session

References

Posts in this series