inacive是指这个连接已经与数据连接了,但没有当前没有处于空闲状态(没有执行SQL)
检查session数:
select
count
(
*
)
from
v$session
检查process数:
select
count
(
*
)
from
v$process
一个自动杀 的job
CREATE
OR
REPLACE
PROCEDURE
"KILL_SESSION"
AS
v_sid number ;
v_serial number ;
killer varchar2 ( 1000 );
CURSOR cursor_session_info is select sid,serial# from v$session where type != ' BACKGROUND ' and status = ' INACTIVE ' and last_call_et > 2700 and username = ' ICWEB ' and machine = ' orc ' ;
BEGIN
open cursor_session_info;
loop
fetch cursor_session_info into v_sid,v_serial;
exit when cursor_session_info % notfound;
killer: = ' alter system disconnect session ''' || v_sid || ' , ' || v_serial || ''' post_transaction immediate ' ;
execute immediate killer;
end loop;
dbms_output.PUT_LINE(cursor_session_info % rowcount || ' users with idle_time>2700s have been killed! ' );
close cursor_session_info;
END ;
/
v_sid number ;
v_serial number ;
killer varchar2 ( 1000 );
CURSOR cursor_session_info is select sid,serial# from v$session where type != ' BACKGROUND ' and status = ' INACTIVE ' and last_call_et > 2700 and username = ' ICWEB ' and machine = ' orc ' ;
BEGIN
open cursor_session_info;
loop
fetch cursor_session_info into v_sid,v_serial;
exit when cursor_session_info % notfound;
killer: = ' alter system disconnect session ''' || v_sid || ' , ' || v_serial || ''' post_transaction immediate ' ;
execute immediate killer;
end loop;
dbms_output.PUT_LINE(cursor_session_info % rowcount || ' users with idle_time>2700s have been killed! ' );
close cursor_session_info;
END ;
/
这样做其实还是治标不治本,最好能够解决连接池自动释放idle进程的问题