DELETE/REMOVE Non Executing Datapump Jobs
Step 1:-
Normally, we can run the below query to find the datapump jobs and get their status:-
SQL> SET lines 150 pages 999
COL OWNER_NAME for a18
COL JOB_NAME for a25
COL OPERATION for a14
COL JOB_MODE for a15
COL STATE for a18
COL DEGREE for 99999
COL ATTACHED_SESSIONS for 99999
COL DATAPUMP_SESSIONS for 99999
SELECT *
FROM dba_datapump_jobs;
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
------------------ ------------------------- -------------- --------------- ------------------ ------ ----------------- -----------------
SYS SYS_EXPORT_SCHEMA_02 EXPORT SCHEMA EXECUTING 1 1 3
SYS SYS_EXPORT_SCHEMA_01 EXPORT SCHEMA NOT RUNNING 0 0 0
Step 2:-
Now, I want to kill "SYS_EXPORT_SCHEMA_01" which is in "NOT RUNNING" state and in order to kill the job, we can use the below procedure
SQL> DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_SCHEMA_01','SYS');
DBMS_DATAPUMP.STOP_JOB (h1,1,0);
END;
/
DECLARE
*
ERROR at line 1:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 1852
ORA-06512: at "SYS.DBMS_DATAPUMP", line 5319
ORA-06512: at line 4
Step 3:-
Since the job is already in "NOT RUNNING" state, we received the above error. To remove the job, identify the master tables which are created for this job.
SQL> SET lines 150
col "OBJECT_TYPE" for a20
col "OWNER.OBJECT" for a40
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;
STATUS OBJECT_ID OBJECT_TYPE OWNER.OBJECT
--------------------- ---------- -------------------- ----------------------------------------
VALID 235524 TABLE SYS.SYS_EXPORT_SCHEMA_01
VALID 236371 TABLE SYS.SYS_EXPORT_SCHEMA_02
Step 4:-
Now, drop the master tables to cleanup the job
SQL> DROP TABLE SYS.SYS_EXPORT_SCHEMA_01;
Table dropped.
Step 5:-
Verify the job is dropped by re-running the statement from Step 1.