select object_name, machine, s.sid, 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 ‘sid, serial#’ 结束会话
当session是active的时候,alter system kill session 只是将session标识为killed状态,并不会释放session持有的资源,所以在执行完alter system kill session 后,看会话还是一直存在,等待PMON进程回收资源和释放锁。
--释放SESSION SQL:
--alter system kill session 'sid, serial#';
alter system kill session '510,24348';
ORA-00031: session marked for kill
增加immediate 参数,也不起作用:
SQL> alter system kill session '510,24348' immediate;
alter system kill session '510,24348' immediate
ORA-00031: session marked for kill
查看状态为"killded"的进程:
select a.spid,b.sid,b.serial#,b.username from v$process a,v$session b
where a.addr=b.paddr and b.status='KILLED';