Oracle Data Pump Export Schema with expdp Command Guide
Oracle Data Pump Export Schema with expdp Command Guide
Oracle Data Pump's expdp utility lets you take a fast, flexible logical backup of any schema in your Oracle database. This post breaks down a simple schema-level export command, explains each parameter, and shows you how to run it safely.
What This Command Does
The command below exports all objects and data from the andy schema into a binary dump file stored in an Oracle directory object called my_dir.
1expdp system/****** schemas=andy dumpfile=andy.dp directory=my_dir
This is a schema-mode export β the most common type of logical backup for a single user's data. It captures tables, indexes, views, stored procedures, sequences, constraints, triggers, and all other objects owned by the andy schema.
Breakdown of Each Parameter
| Parameter | Value | Meaning |
|---|---|---|
expdp | β | Starts the Oracle Data Pump Export utility |
system/****** | Credentials | Connects as the SYSTEM user (password masked); must have EXP_FULL_DATABASE privilege |
schemas=andy | andy | Tells Data Pump to export only the andy schema |
dumpfile=andy.dp | andy.dp | Name of the output dump file written to the directory object |
directory=my_dir | my_dir | Oracle directory object pointing to the OS folder where the dump file is saved |
What Is an Oracle Directory Object?
A directory object is a database alias that maps to a real folder on the server's file system. You do not use an OS path directly in the expdp command. Instead, a DBA creates the directory object first:
1CREATE OR REPLACE DIRECTORY my_dir AS '/u01/oracle/exports';
2GRANT READ, WRITE ON DIRECTORY my_dir TO system;
The DIRECTORY parameter in the export command tells Data Pump to write the dump file and log file into that mapped folder. This separation of the OS path from the command is a security and portability feature of Data Pump.
What Gets Exported
When you run a schema-mode export with schemas=andy, Oracle Data Pump exports the following object types owned by that user:
- Tables (structure + data)
- Indexes and constraints
- Views and materialized views
- Stored procedures, functions, and packages
- Sequences and synonyms
- Triggers
- Grants and object privileges
How Data Pump Works Internally
When you run expdp, Oracle creates a Master Table inside the exporting user's schema to track job progress and metadata. The utility then uses the internal DBMS_DATAPUMP API to extract data and write it into the binary dump file. Because Data Pump runs server-side (not client-side like the old exp utility), it is significantly faster, especially for large schemas.
Key Points and Best Practices
- Always use a directory object β never try to pass a raw OS path. The directory must exist on the database server and have correct OS permissions.
- Run as a privileged user β
SYSTEMor any user with theEXP_FULL_DATABASErole can export any schema. - Mask your password in scripts β the
******in the command above is best practice; use a wallet or@connect identifier in automated jobs to avoid plain-text passwords. - Add a log file for debugging β append
logfile=andy_export.logto capture any warnings or errors during the export. - The
.dpextension β Oracle does not enforce a specific extension;.dmpis the common convention, but.dpworks fine. schemas=replaces the oldowner=β if you used the legacyexputility, note thatSCHEMASis the modern equivalent of the oldOWNERparameter.
Example with Log File Added
A more complete, production-ready version of the command looks like this:
1expdp system/****** schemas=andy dumpfile=andy.dp directory=my_dir logfile=andy_export.log
Adding logfile= writes all job messages, warnings, and completion status to andy_export.log in the same my_dir directory.
Required Privileges
Before running the command, confirm these are in place:
- The
systemuser (or your chosen user) hasEXP_FULL_DATABASErole - The directory object
my_direxists:SELECT * FROM dba_directories; - Read/Write grants on the directory are assigned to the user running
expdp - The OS folder that
my_dirpoints to exists on the database server and is writable by the Oracle OS user
References
- Oracle Data Pump Export Utility β Oracle 19c Official Documentation β Full reference for all
expdpparameters, modes, and export options - Oracle Data Pump (expdp, impdp) β oracle-base.com β Practical guide covering schema, table, and full export examples with
DBMS_DATAPUMPAPI - Data Pump Export Parameters β Oracle 23c Documentation β Complete list of all command-line parameters available for
expdp - Oracle DIRECTORY Parameter for Data Pump β Stack Overflow β Community explanation of how directory objects work with Data Pump
- Oracle Data Pump Best Practices β Oracle White Paper (PDF) β Oracle's official best practices guide for using Data Pump in migrations and backups
- Data Pump LOGTIME, DUMPFILE, PARFILE β dbi-services.com β Explains log output, file naming patterns, and parameter file usage for Data Pump in Oracle 12c
- Data Pump Export of Application Schema β Oracle 26c Docs β Covers exporting schemas protected by Oracle Database Vault
- Masterclass on Oracle DataPump Utility β LinkedIn β In-depth walkthrough of how
expdpcreates a Master Table and uses the Data Pump API internally