Oracle Database - Enterprise Edition - Version 9.2.0.8 and later
Information in this document applies to any platform.
目标:
怎么得到正在运行job的session id
--->注意:本文说的job包括 由DBMS_JOB 创建的 和 DBMS_SCHEDULER 创建的。
解决方案:
如果job 使用DBMS_JOB package创建,请使用如下语句:
set Feedback off
alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
set Feedback on
select jr.job,s.username,s.sid,s.serial#,p.spid,s.lockwait,s.logon_time
from dba_jobs_running jr,v$session s,v$process p
where jr.sid = s.sid
and s.paddr = p.addr
order by jr.job;
如果job 使用DBMS_SCHEDULER 创建,请使用如下语句:
set Feedback off
alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
set Feedback on
select rj.job_name,s.logon_time
from dba_scheduler_running_jobs rj,v$process p
where rj.session_id = s.sid
and s.paddr = p.addr
order by rj.job_name;
-----------------------------------------------释放相关的会话---------------------------------------------------------------------------------------------------------
--锁表查询sqlSELECT object_name,machine,s.serial#
FROM gv$locked_object l,dba_objects o,gv$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid;
找到被锁定的表,解锁 ----------------------------------------------
ALTER system kill session '23,1647';