oracle killed会话不释放
一般情况下,在杀一个会话的时候,直接执行alter system kill session ‘sid,serial#’;
Administrator's Guide说,当session是active的时候,alter system kill session 只是将session标识为killed
或者pseudo状态,并不会释放session持有的资源,所以我们在执行完alter system kill session 后,看会话还
是一直存在。
这种情况下可以使用 immediate选项,强制立即Kill会话,如下:
SQL> alter system kill session '3964,51752' immediate;
SQL Language Reference 里对Immediate的解释是:IMMEDIATE Specify IMMEDIATE
to instruct Oracle
Database to roll back ongoing transactions, release all session locks, recover the entire session state,
and return control to you immediately.
另外我们也可以使用alter system disconnect session
The POST_TRANSACTION
setting allows ongoing transactions to complete before the session is disconnected.
If the session has no ongoing transactions, then this clause has the same effect described for as KILL
SESSION
.
The IMMEDIATE
setting disconnects the session and recovers the entire session state immediately, without
waiting for ongoing transactions to complete.
If you also specify POST_TRANSACTION
and the session has ongoing transactions, then the IMMEDIATE
keyword is ignored.
If you do not specify POST_TRANSACTION
, or you specify POST_TRANSACTION
but the session has no ongoing transactions,
then this clause has the same effect as described for KILL
SESSION
IMMEDIATE
.
ORACLE建议的DCD解决方法
通过OS杀进程终止会话
SELECT spid, osuser, s.program, schemaname FROM gv$process p, gv$session s WHERE p.addr = s.paddr;
kill -9 5745
ps -ef | grep pmon_$ORACLE_SID | awk '{print $2}' | xargs kill –9 #kill 一批会话
2. WINDOWS
orakill <instance_name> <spid>
如果会话已经在DB里killed,上面的SQL已经查不出spid,可以用下面的SQL查出SPID
select addr, pid, spid FROM v$process p where addr in (select p.addr from v$process p where pid <> 1 minus select s.paddr from v$session s)优质内容筛选与推荐>>