日期:2014-05-16  浏览次数:20468 次

oracle通过游标方式删除所有以NO开头的session

declare
???????????? cursor?? cur_sess?? is
?????????????????? select?? sid,?? serial#
????????????????????? from?? v$session
???????????????????? where???
????????????????????????? username like 'NO%';
?????????? w_sid?? number;
???????????? w_serial?? number;
???????? begin
?????????? open?? cur_sess;
?????????? loop
?????????????? fetch?? cur_sess?? into?? w_sid,w_serial;
?????????????? if?? cur_sess%notfound?? then
?????????????????? exit;
????????????? end?? if;
?????????????? execute?? immediate?? 'alter?? system?? kill?? session?? '''||w_sid|| ', '||w_serial|| '''';
?????????? end?? loop;
???? end;