Oracle Data Pump: export and import schemas with expdp and impdp
Data Pump moves schemas, tables or whole databases between Oracle databases as dump files. Set up a directory object, export with expdp and import with impdp, remapping as needed.
Not checked by a trusted editor yet Last edited Outdated?
Data Pump (expdp and impdp) is Oracle’s logical export and import tool. It writes table data and object definitions into dump files that another Oracle database can load. Typical uses: copy a schema from production to test, move an application to a new server or version, or keep an extra logical copy next to RMAN backups. It does not replace RMAN for disaster recovery.
Data Pump runs inside the database server. The client tools only start and watch a job; dump files are written and read by the database on the server’s file system, through a directory object.
1. Create a directory object
Create the operating-system directory first: Oracle does not check that the path exists. Then, as a DBA connected to the PDB:
CREATE DIRECTORY dp_dir AS '/u01/app/oracle/dpdump/shop';
GRANT READ, WRITE ON DIRECTORY dp_dir TO appuser;
Privileged users can also use the default directory object DATA_PUMP_DIR. A user without the DATAPUMP_EXP_FULL_DATABASE role can export only their own schema; importing other schemas needs DATAPUMP_IMP_FULL_DATABASE on the target.
2. Export a schema
Connect to the PDB’s service. The schema mode is the default, but naming it makes the command clear. Oracle advises not to run Data Pump as SYSDBA unless Oracle Support asks you to.
expdp [email protected]:1521/orclpdb1.example.com \
SCHEMAS=appuser DIRECTORY=dp_dir \
DUMPFILE=appuser_%U.dmp LOGFILE=appuser_exp.log \
PARALLEL=2 FLASHBACK_TIME=systimestamp
%Uexpands to 01, 02 and so on, so parallel workers can each write their own file.FLASHBACK_TIME=systimestampmakes the export consistent as of its start time, which matters when the application keeps writing.FULL=YESexports the whole database (needsDATAPUMP_EXP_FULL_DATABASE);TABLES=appuser.ordersexports single tables.CONTENT=METADATA_ONLYexports only definitions, no rows.
Use a parameter file for anything with quotes
Filters such as EXCLUDE, INCLUDE, QUERY and FLASHBACK_TIME="TO_TIMESTAMP(...)" contain quotes that shells mangle. Oracle recommends putting them in a parameter file:
SCHEMAS=appuser
DIRECTORY=dp_dir
DUMPFILE=appuser_tables.dmp
LOGFILE=appuser_tables.log
INCLUDE=TABLE:"IN ('ORDERS', 'CUSTOMERS')"
expdp [email protected]:1521/orclpdb1.example.com PARFILE=appuser_tables.par
3. Copy the files and import
Copy the dump files into the directory behind a directory object on the target server, create the same directory object there, then import. REMAP_SCHEMA loads objects into a different user, and REMAP_TABLESPACE into a different tablespace:
impdp [email protected]:1521/testpdb.example.com \
DIRECTORY=dp_dir DUMPFILE=appuser_%U.dmp LOGFILE=appuser_imp.log \
REMAP_SCHEMA=appuser:appuser_test \
REMAP_TABLESPACE=app_data:test_data
TABLE_EXISTS_ACTION decides what happens when a table already exists: SKIP (the default), APPEND, TRUNCATE or REPLACE.
Warning: TRUNCATE deletes the existing rows and REPLACE drops and recreates the table. Before using either, check the target connection string and run the import with SQLFILE first to see what it would do:
impdp [email protected]:1521/testpdb.example.com \
DIRECTORY=dp_dir DUMPFILE=appuser_%U.dmp SQLFILE=dp_dir:preview.sql
With SQLFILE, impdp writes the DDL it would run into preview.sql and changes nothing in the database.
4. Check the result
- Read the log file end to end; failed objects are reported with an
ORA-code, and the last lines tell you whether the job completed with errors. - Compare object counts:
SELECT object_type, COUNT(*) FROM dba_objects WHERE owner = 'APPUSER_TEST' GROUP BY object_type. - Recompile invalid objects and check grants to roles or users that do not exist on the target.
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0222 Connecting to Oracle: SQL*Plus, SQLcl, EZConnect, tnsnames.ora and the listener Clients reach an Oracle database through the listener, using an Easy Connect string or a tnsnames.ora alias. Here are the formats, the… Intermediate · Cheat sheet · Linux, macOS, Windows Article Administration · Concepts & tools 15 Oct 2026
- 0223 Oracle users, roles and tablespaces: setup script and usage report (SQL) A SQL*Plus/SQLcl script that creates a tablespace, a role and an application user inside a PDB, then reports tablespace usage from the… Intermediate · Step by step · Any system Script Administration · Security & access 15 Oct 2026
- 0224 RMAN backup basics: ARCHIVELOG mode, a nightly backup script and restore Enable ARCHIVELOG mode, set an RMAN retention policy, run a nightly full backup with archived logs from cron, and learn the restore… Advanced · Step by step · Linux Script Administration · Backup with RMAN 15 Oct 2026
- 0226 Fix: ORA-12541: TNS:no listener The client reached the host but nothing was listening on that port. Start or fix the Oracle listener, or correct the host… Intermediate · Fixes an error · Linux, Windows Article Administration · Concepts & tools 15 Oct 2026
- 0227 Fix: ORA-01017: invalid username/password; logon denied Oracle rejected the login. Check the password (case-sensitive), that you connect to the right PDB service, and whether the account is locked… Intermediate · Fixes an error · Any system Article Administration · Security & access 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Commitpedia +3,948 chars