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. Without a valid directory object, Data Pump jobs will fail or fall back to an installation default path that 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, DATA_PUMP_DIR must be created inside each PDB individually β€” the CDB root directory object does not automatically apply to PDBs.

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 (equal to or larger than the database itself for full exports). Monitor free space on /u01/ora_backup/datapump regularly.
  • Security. Restrict the CREATE ANY DIRECTORY privilege tightly. A user with this privilege can point a directory object to any OS path β€” including sensitive system files.

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$PARAMETERUseful to check db_recovery_file_dest related settings

References

Posts in this series