首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

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

2012-07-27 
oracle通过游标方式删除所有以NO开头的sessiondeclare ???????????? cursor?? cur_sess?? is ????????????

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;

热点排行