Kill all sessions of a specified user name

shiyihai發表於2007-05-09

declare
ora_user varchar2(30) default 'SCOTT';

begin
execute immediate 'alter user '||ora_user||' account lock';
for crs in (select sid,serial# from v$session where username = ora_user) loop
execute immediate 'alter system kill session '''||crs.sid||','||crs.serial#||'''';
end loop;
end;
/

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/38542/viewspace-914205/,如需轉載,請註明出處,否則將追究法律責任。

相關文章