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. 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 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,
DATA_PUMP_DIRmust 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_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 (equal to or larger than the database itself for full exports). Monitor free space on
/u01/ora_backup/datapumpregularly. - Security. Restrict the
CREATE ANY DIRECTORYprivilege tightly. A user with this privilege can point a directory object to any OS path β including sensitive system files.
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 | Useful to check db_recovery_file_dest related settings |
References
- Oracle Data Pump Overview β Oracle 18c Documentation β Official Oracle 18c guide to Data Pump architecture, directory objects, default
DATA_PUMP_DIRsetup, and privilege requirements. - 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. - How to Change Oracle Default Data Pump Directory β Stack Overflow β Community discussion and examples on updating
DATA_PUMP_DIRpath and using theDIRECTORYparameter inimpdp. - Pluggable Databases and DATA_PUMP_DIR β markusdba.net β Detailed walkthrough of
ORA-39087errors with PDBs and how to correctly createDATA_PUMP_DIRinside pluggable databases. - 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.