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
| Part | What It Means |
|---|---|
CREATE DIRECTORY | SQL command that creates a new database directory object |
data_pump_dir | The 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:
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).data_pump_dir— This is the logical name Oracle uses internally. Data Pump utilities (expdp,impdp) reference this name, not the physical path.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 DIRECTORYsystem privilege can run this command. - Create the OS folder first. The physical path
/u01/ora_backup/datapumpmust exist on the server before the directory object is useful. Usemkdir -p /u01/ora_backup/datapumpand then set correct ownership withchown oracle:oinstall /u01/ora_backup/datapump. - Grant access to users. After creating the directory, you must grant
READandWRITEprivileges to any database user who will run Data Pump jobs. CREATE OR REPLACEis safer for re-runs. UseCREATE 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_DIRis defined as a unique path for each PDB. To see the path a PDB uses, connect to that PDB and run theDBA_DIRECTORIESquery in Step 4. One write-up on 12.1.0.2 found thatCREATE OR REPLACE DIRECTORY data_pump_dirinside a PDB fails withORA-65040, and it used a separate directory name (DATA_PUMP_DIR_PDB) with theDIRECTORY=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_backupon 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_DIRis the Oracle standard default name. Using this name means you do not need to specifyDIRECTORY=on everyexpdp/impdpcommand for privileged users — Oracle uses it automatically. - Check the path after upgrades. Oracle may redefine the
DATA_PUMP_DIRpath during database upgrades. Always verify the path after an upgrade with theDBA_DIRECTORIESquery above. - Space planning. Export dump files can be very large for full exports. Monitor free space on
/u01/ora_backup/datapumpregularly. - Security. Restrict the
CREATE ANY DIRECTORYprivilege 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
| View | Purpose |
|---|---|
DBA_DIRECTORIES | Lists all directory objects, their owners, and OS paths |
ALL_DIRECTORIES | Lists directory objects the current user can access |
V$PARAMETER | Shows the initialization parameters currently in effect for the session |
References
- Oracle Data Pump Overview — Oracle 18c Documentation — Official Oracle 18c guide covering the default
DATA_PUMP_DIRobject, creating directory objects, and theREADandWRITEgrants. - Oracle Data Pump Overview — Oracle 21c Documentation — Oracle 21c documentation covering
DATA_PUMP_DIRin multitenant CDB/PDB environments and directory object best practices. - Management of File Locations in Oracle Data Pump — Oracle 26 Documentation — Latest Oracle documentation explaining how the
DIRECTORYparameter works in Data Pump jobs and the defaultDATA_PUMP_DIRobject behavior. - DBMS_DATAPUMP Package — Oracle 21c Documentation — Oracle PL/SQL package reference for programmatic Data Pump operations, including directory usage in the API.
- Oracle 18c Datapump DIRECTORY Parameter — oracledbwr.com — Practical guide explaining the
DIRECTORYparameter, how to create directory objects, and how to grant user access. - Pluggable Databases and DATA_PUMP_DIR — markusdba.net — Walkthrough on Oracle 12.1.0.2 of the
ORA-39087error with PDBs; it shows that recreatingDATA_PUMP_DIRinside a PDB fails withORA-65040and uses a new directory name,DATA_PUMP_DIR_PDB, instead. - Configure a Data Pump Directory for Local Installations — Oracle Industry Docs — Step-by-step installation guide for setting up the Data Pump directory in local Oracle database environments.