日期:2014-05-17 浏览次数:20863 次
create or replace procedure dropUser(user_name in varchar2) authid current_user is
cnt integer;
sqlStr varchar2(1000);
begin
sqlStr := 'alter user ' || user_name || ' account lock';
execute immediate sqlStr;
for x in (select * from v$session where username=user_name)
loop
--清除用户session
sqlStr := 'alter system disconnect session ''' || x.sid || ',' || x.serial# || ''' immediate';
execute immediate sqlStr;
end loop;
loop
select count(*) into cnt from v$session where username=user_name;
exit when cnt=0;
dbms_lock.sleep(3);
end loop;
sqlStr := 'drop user' || user_name || 'cascade';
end dropUser;
/
exec dropUser('user1');