查询某个用户会话 :
select username,sid,serial# from v$session t where upper(t.username) = 'test';
查系统中表空间用户占用的进程 :
select p.spid,s.sid,s.serial# FROM v$session s,v$process p WHERE p.addr=s.paddr and upper(s.username) = 'test';
删除单个用户会话进程:
alter system kill session 'sid,serial#';
如果使用alter kill杀不掉用户会话,则需要在系统执行kill -9命令将其杀掉。
批量生成KILL会话的SQL语句:
SELECT 'alter system kill session ''' || ta.sid || ',' || ta.serial# || ''';',
'alter system disconnect session ''' || ta.sid || ',' || ta.serial# || ''' immediate;',
'host orakill ' || tc.instance_name || ' ' || tb.spid,
'kill -9 ' || tb.spid,
tb.spid,
ta.osuser,
tb.program,
ta.terminal,
ta.program
FROM v$session ta, v$process tb, v$instance tc
WHERE tb.addr = ta.paddr
AND ta.sid = &yoursid;