Oracle expdp Schema Export Using Data Pump
Oracle expdp Schema Export Using Data Pump
Oracle Data Pump's expdp utility lets you export a full database schema — including tables, indexes, constraints, and data — into a portable dump file. This guide breaks down the single-line command that does exactly that for the andy schema.
Purpose of This Command
The goal of this command is to create a logical backup of a single Oracle database schema called andy. The export produces a binary dump file (andy.dp) saved to a pre-defined Oracle directory object (my_dir) on the server. This backup can later be imported into the same or a different Oracle database using impdp.
Schema-mode export is the default export mode in Oracle Data Pump and is ideal for migrating, cloning, or backing up a single user's objects without touching the rest of the database.
The Command
1expdp system/****** schemas=andy dumpfile=andy.dp directory=my_dir
Breakdown of Each Part
| Part | Value | What It Does |
|---|---|---|
expdp | — | Calls the Oracle Data Pump Export executable |
system/****** | Credentials | Connects as the system user (password hidden) |
schemas=andy | andy | Tells Data Pump to export only the andy schema |
dumpfile=andy.dp | andy.dp | Sets the name of the output dump file |
directory=my_dir | my_dir | Points to an Oracle Directory Object for file output |
Each parameter is a keyword argument passed directly on the command line.
What Is a Directory Object?
An Oracle Directory Object is a database-level pointer that maps a short name (like my_dir) to a real path on the server's file system (like /backup/oracle/).
You must create this object before running the export, and you must grant READ and WRITE privileges on it to the user running expdp. The command to create and grant looks like this:
1-- Run as SYSDBA or a privileged user
2CREATE OR REPLACE DIRECTORY my_dir AS '/backup/oracle/';
3GRANT READ, WRITE ON DIRECTORY my_dir TO system;
Oracle also states that a user who is not privileged needs a directory object created by a DBA, or by a user with the CREATE ANY DIRECTORY privilege. An invalid directory object in the DIRECTORY parameter stops the job before it starts.
What Gets Exported?
When you run a schema-mode export, Oracle Data Pump exports the objects that belong to that schema, including tables with their rows. Excluding a table also excludes its indexes and triggers, so those travel with the table. To see the exact object types a schema export handles on your version, query SCHEMA_EXPORT_OBJECTS. The OBJECT_PATH column lists the valid types.
If you have the DATAPUMP_EXP_FULL_DATABASE role, you can also export the user definitions and the system and role grants for the schemas you name. The SYS schema cannot be a source schema for an export.
Why Use system to Export Another Schema?
Exporting a schema you do not own needs the DATAPUMP_EXP_FULL_DATABASE role. Oracle creates this role when you run the standard database creation scripts. Without it, a user can only export their own schema. Check that the account you use holds the role before you run the job. system also has read and write access to the default DATA_PUMP_DIR directory object.
The Dump File: andy.dp
The output file andy.dp is a proprietary Oracle binary format. It is not a plain SQL script. You cannot open it in a text editor and read it. It is designed specifically to be re-loaded by the impdp (Data Pump Import) utility.
- The file is written to the directory mapped by
my_diron the database server, not on your local client machine. - By default, if a file with the same name already exists, the job will fail — use
REUSE_DUMPFILES=yto overwrite.
How to Add a Log File
The command above does not include a logfile parameter, so Data Pump writes its default log file, export.log, in the my_dir directory (use NOLOGFILE=YES to suppress it). It is a good practice to name the log file explicitly:
1expdp system/****** schemas=andy dumpfile=andy.dp directory=my_dir logfile=andy_exp.log
The log file records job progress, object counts, warnings, and errors. It is saved to the same my_dir directory unless you specify a different directory for it.
How to Import This Dump File
To restore or migrate the andy schema using the dump file, use impdp:
1impdp system/****** schemas=andy dumpfile=andy.dp directory=my_dir logfile=andy_imp.log
You can also remap the schema to a different target user during import with REMAP_SCHEMA=andy:new_user, which loads all objects from the source schema into the target schema. Oracle's page says the import can create a missing target schema, except for REMAP_SCHEMA for the SYSTEM user.
Key Points and Tips
- Password security: Never store plain-text passwords in scripts. Use Oracle Wallet or an external password store for automated jobs.
- File extension: If you give no extension, Export uses
.dmp. This command namesandy.dpexplicitly. Choose a consistent naming convention. - Parallel export: For large schemas, add
PARALLEL=4(or higher) along with a wildcard dumpfile likedumpfile=andy_%U.dmpto write multiple files simultaneously. - Compression: Add
COMPRESSION=ALLto reduce dump file size on large schemas. TheALLoption requires that the Oracle Advanced Compression option is enabled. - Exclude objects: Use
EXCLUDEto skip object types, for exampleEXCLUDE=VIEW,PACKAGE,FUNCTION. Excluding an object also excludes its dependent objects. Check a type name such asSTATISTICSagainstSCHEMA_EXPORT_OBJECTSbefore you rely on it. - Monitor a running job: Attach to a running job with
expdp system/****** attach=job_nameand use theSTATUScommand inside the interactive prompt.
Quick Reference: Useful expdp Parameters
| Parameter | Example | Purpose |
|---|---|---|
LOGFILE | logfile=andy.log | Saves a text log of the job |
PARALLEL | parallel=4 | Uses multiple worker threads |
COMPRESSION | compression=all | Compresses dump file |
REUSE_DUMPFILES | reuse_dumpfiles=y | Overwrites existing dump file |
EXCLUDE | exclude=statistics | Skips specific object types |
CONTENT | content=data_only | Exports only data, no DDL |
FLASHBACK_TIME | flashback_time=systimestamp | Consistent export based on the current system time |
References
- Oracle Data Pump Export Utility — Official Oracle 19c Documentation — Full reference for the
expdpcommand, all parameters, and export modes. - Oracle Data Pump Export Parameters — Oracle 26c Docs — Complete list of every available
expdpcommand-line parameter with descriptions and examples. - Oracle Data Pump (expdp, impdp) — oracle-base.com — Practical, example-driven guide covering schema export, import, REMAP_SCHEMA, INCLUDE/EXCLUDE, and the
DBMS_DATAPUMPPL/SQL API. - Oracle Data Pump Best Practices — Oracle White Paper (PDF) — Official Oracle best practices guide covering parallelism, compression, cloud migration, and performance tuning for Data Pump.
- Overview of Oracle Data Pump — Oracle 18c Documentation — Explains how Data Pump uses Directory Objects, the
DBMS_DATAPUMPpackage, and the relationship betweenexpdp/impdpclients. - Performing a Data Pump Export of an Application Schema — Oracle Database Vault Guide — Covers exporting schemas protected by Oracle Database Vault realms and command rules.
- Use of DIRECTORY in EXPDP/IMPDP — Oracle Forums — Community discussion on how directory objects work, common errors, and how to create and grant them correctly.
- Masterclass on Oracle DataPump Utility Part II — LinkedIn — In-depth article on
expdp/impdpinternals, the Master Table mechanism, parameter files (PARFILE), and advanced job management.