Datapump
QuickRef for control
- connect to a running job:
impdp system attach=IMPORT_FULL - at the prompt:
statusto show the statusstop_jobto stop it (also:STOP_JOB=IMMEDIATE)start_jobto resume it (alsoSTART_JOB=SKIP_CURRENT)kill_jobto kill it permanentlycontinue_client: return to logging mode (restarts job if idle)exit_client: quits the client session and leaves the job runningparallel=8: change the number of workers for this jobhelp: show available commands
Find the job
If you specified the job name when starting the datapump action, you already know it:
expdp system full=y JOB_NAME=EXPORT_FULL
But even if not, you can find it querying the database:
SELECT owner_name, job_name, operation, job_mode, state
FROM dba_datapump_jobs;
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE
---------- ------------- ---------- ---------- ------------
SYSTEM IMPORT_FULL IMPORT FULL EXECUTING
Job details
Now let's see what the datapump is doing – especially when the log does not seem to update. This certainly is the case with very large tables where you want to see the progress – or if the datapump job seems to be stuck:
col object_schema for a20
col object_name for a30
set lines 200
set pages 100
select * from (
select object_schema, object_name,
round(size_estimate/power(1024,3),1) est_gb,
to_char(start_time, 'YYYY-MM-DD HH24:MI:SS') as start_time,
state,
round(total_bytes / power(1024, 3)) as total_GB,
work_item
from system.IMPORT_FULL
where object_name is not null
and object_schema is not null
and object_type_path = 'DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA'
order by start_time
) where rownum < 10;
Issues
IMPDP creates huge amounts of UNDO
The most common cause of high UNDO generation during an IMPDP job is that the table pre-exists in the target database and one or more indexes exist on that table. During the import job, those indexes will be maintained for every row inserted. To resolve that problem, ensure that the table that needs to be imported does not pre-exist in the target database, but let import create the table.
This means: do not use TABLE_EXISTS_ACTION=APPEND or TABLE_EXISTS_ACTION=TRUNCATE parameter for the Import Data Pump job unless this is really required.
(from: MOS Note 1670349.1)
This usually effects larger imports only – but „large“ is quite relative here. As a rule of the thumb, if you have a table of a size approaching the size of your undo tablespace, you will probably run into this issue: your import will stall with an ORA-30036 and the undo tablespace full.
TABLE_EXISTS_ACTION=TRUNCATE: rather useREPLACETABLE_EXISTS_ACTION=APPEND: before starting the import, disable all constraints and drop all indexes for affected tables (re-enable and re-create afterwards).
Datapump crashed (or was terminated); how to clean up?
This is described in MOS Note 336014.1. Basically, you have to identify the left-overs and remove them:
-- locate datapump jobs
SELECT owner_name, job_name, rtrim(operation) "OPERATION",
rtrim(job_mode) "JOB_MODE", state, attached_sessions
FROM dba_datapump_jobs
WHERE job_name NOT LIKE 'BIN$%'
ORDER BY 1,2;
-- Ensure that the jobs listed above are not active: status should be 'NOT RUNNING'.
-- Ensure that none of the jobs was just temporarily suspended (using STOP_JOB).
-- (if you e.g. can connect to it via "impdp job_name=<name>" and get a status).
-- Now identify orphan DataPump external tables (as sysdba):
SELECT owner,object_name,object_type, status,
to_char(created, 'dd-mon-yyyy hh24:mi:ss') created,
to_char(last_ddl_time, 'dd-mon-yyyy hh24:mi:ss') last_ddl_time
FROM dba_objects
WHERE object_name like 'ET$%';
SELECT owner, table_name, default_directory_name, access_type
FROM dba_external_tables
ORDER BY 1,2;
-- correlate information given by the two queries to identify temporary external tables
-- of the orphaned datapump jobs. Then drop them:
DROP TABLE <owner>.<table_name> purge;
-- Now, similarly for the master table:
SELECT o.status, o.object_id, o.object_type,
o.owner||'.'||object_name "OWNER.OBJECT"
FROM dba_objects o, dba_datapump_jobs j
WHERE o.owner=j.owner_name AND o.object_name=j.job_name
AND j.job_name NOT LIKE 'BIN$%' ORDER BY 4,2;
SELECT table_name, owner
FROM dba_external_tables;
-- For jobs that were stopped in the past and won't be restarted anymore, delete the master table:
DROP TABLE <owner>.<table_name>;
PURGE dba_recyclebin;
-- Re-run the query on dba_datapump_jobs and dba_objects above to make sure they're all gone.
-- Repeat steps if needed.
Should the crashed/terminated datapump process leave you with unusually heavy UNDO processing, you can check Analyzing heavy UNDO operations for how to deal with this.
Other notes
A full export does not, by default, export system schemas that contain Oracle-managed data and metadata. Examples of system schemas that are not exported by default include
SYS,ORDSYS, andMDSYS.
Hence it should be safe to do a full import on a higher database version – e.g. importing a full dump made with 12c into an Oracle 19c database.
- never export statistics – they will be useless after import anyway (as all
your tables and indexes are reorganized). Instead, export without statistics
(
exclude=statistics) and gather fresh statistics after import. EXCLUDEandINCLUDEparameters are mutually exclusive – so you cannot use both in the same run (to e.g. exclude a broader set and then include parts of it again)- if a crashed/aborted import job left it’s „control table“, make sure to
drop it first before starting over. You can find it in the schema used
to run the import, it carries the same name as the job name you specified
(see Find the job above). With the above import example, it
would e.g. be
DROP TABLE system.import_full;. Also see: How do I kill a non-running impdp job? and „How to cleanup orphaned datapump jobs“ MOS Note 336014.1. impdpmight utilize a lot of UNDO and TEMP, so make sure you’ve got enough space there.- to reduce archive logging during import, you can make use of the
transform=disable_archive_logging:yparameter (e.g. in your parameter file). You can also reduce that to specific objects, liketransform=disable_archive_logging:y:index(to only ommit it for indexes) ortransform=disable_archive_logging:Y:tablename(to only ommit it for a specific table). - to list all available parameters, use e.g.
impdp help=y
Sources and Further Readings
- Kill, cancel, resume or restart datapump expdp and impdp jobs
- Queries to Monitor Datapump Jobs
- impdp stalls for no apparent reason
- EXPDP/IMPDP hängen lange Zeit und sind dann sehr langsam
- MOS Note 336014.1: How to cleanup orphaned datapump jobs
- What Happens To Undo Tablespace During DataPump Import And How To Fix It
(also see: MOS Note 727894.1 / 735366.1 / 1670349.1) - Performance hints: MOS Note 1611373.1
- Oracle DataPump Quick Start: MOS Note 413965.1
