作者:mobiledu2502883257 | 来源:互联网 | 2014-07-09 16:02
oracle强制删除用户强制删除关联的sessionwww.2cto.comJava代码DECLAREu_sidvarchar2(50);u_serialnumbervarchar2(50);u_namevarchar2(50);CURSORc1ISselecttrim(s.sid),tr...
oracle强制删除用户
强制删除关联的session
www.2cto.com
DECLARE
u_sid varchar2(50);
u_serialnumber varchar2(50);
u_name varchar2(50);
CURSOR c1 IS select trim(s.sid),trim(s.serial#)
from v$session s,v$process p
where s.paddr = p.addr and (s.username=u_name);
BEGIN
-- 替换用户名,必须大写
u_name:='CARMOT_DEMO2';
OPEN c1;
LOOP
FETCH c1 INTO u_sid,u_serialnumber;
EXIT WHEN c1%NOTFOUND;
EXECUTE IMMEDIATE 'alter system kill session '||''''||trim(u_sid)||','||trim(u_serialnumber)||'''';
END LOOP;
END;
/
删除用户
Java代码
SQL> drop user carmot_demo2 cascade;