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

强制删除用户

强制删除关联的session

?

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;
/

?

删除用户

?

SQL> drop user carmot_demo2 cascade;
?