在oracle中,通过alter system kill session 'sid,serial#'查杀会话后,会话所持有的事务可能需要提交或回滚,此时该会话会被标记成killed,但是资源还没有释放,此时重复执行alter system kill session 'sid,serial#'时,会出现ORA-00031错误
此时只要将该会话的SPID找出来,从操作系统中杀掉该进程即可。
SELECT P.SPID, S.SID, S.SERIAL#, S.USERNAME, S.PROGRAM
FROM V$PROCESS P, V$SESSION S
WHERE P.ADDR=S.PADDR AND S.STATUS='KILLED';
SPID SID SERIAL# USERNAME PROGRAM
------------------------------------------------------------------------ ---------- ---------- ---------- -------------------------
13755 1632 20355 ZJHIS emr_yzbjq.exe
SQL> !ps -ef | grep 13755
oracle 13755 1 0 15:34 ? 00:00:01 oracleorcl (LOCAL=NO)
oracle 20230 19615 0 17:13 pts/0 00:00:00 /bin/bash -c ps -ef | grep 13755
oracle 20232 20230 0 17:13 pts/0 00:00:00 grep 13755
SQL> !kill -9 13755
SQL> !ps -ef | grep 13755
oracle 20316 19615 0 17:14 pts/0 00:00:00 /bin/bash -c ps -ef | grep 13755
oracle 20318 20316 0 17:14 pts/0 00:00:00 grep 13755