1)查询数据库中的数据泵作业
SET lines 200
COL owner_name FORMAT a10
COL job_name FORMAT a20
COL state FORMAT a12
COL operation LIKE state
COL job_mode LIKE state
COL owner.object for a50
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;
输出内容如下
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE ATTACHED_SESSIONS
---------- -------------------- ------------ ------------ ------------ -----------------
SYS FULL_EXPORT EXPORT FULL NOT RUNNING 0
2)确保数据泵作业不是活跃的,状态应该是 'NOT RUNNING'
3)确认状态是 'NOT RUNNING' 的作业不是被临时停止,而是一个失败的作业
4)找到相关的主表
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 17621591 TABLE SYS.FULL_EXPORT
5)对于已经停止,而且不打算再重新启动的作业,删除主表
drop table SYS.FULL_EXPORT;
如果表名混合大小写的话,在删除时需要使用双引号
drop table SYSTEM."impdp_SCHEMA_STGMDM_04102015_1";
drop table SYSTEM."impdp_schema_STGMDM_10202014_0";
6)重新运行步骤 1 和 4 的查询,如果 dba_datapump_jobs 中仍然有作业,但是这些作业的主表已经被删除,用作业的属主清理它,示例:
CONNECT scott/tiger
SET serveroutput on
SET lines 100
DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_TABLE_01','SCOTT');
DBMS_DATAPUMP.STOP_JOB (h1);
END;
/
请注意,在调用 STOP_JOB 过程后,可能需要一些时间才能删除该作业。查询视图 user_datapump_jobs 以检查作业是否被删除:
CONNECT scott/tiger
SELECT * FROM user_datapump_jobs;