删除用户的存储过程

来源:互联网 发布:js模块化开发框架 编辑:程序博客网 时间:2024/04/30 18:35

create or replace procedure prc_drop_user( iv_user_name in varchar2)

authid current_user

is

    vv_err_info varchar2(300);

    cursor c_session is

      select sid, serial# serial

        from v$session

       where username = upper(iv_user_name);

    c_session_row c_session%rowtype;

begin

 

    execute immediate 'alter user ' || iv_user_name || ' identified by passwdtemp';

    for c_session_row in c_session loop

        execute immediate 'alter system kill session ''' || c_session_row.sid || ',' || c_session_row.serial || '''';

    end loop;

    execute immediate 'drop user ' || iv_user_name || ' cascade';

 

exception

    when others then

        vv_err_info := sqlcode || substr(sqlerrm,1,300);

        DBMS_OUTPUT.PUT_LINE('Drop user '|| iv_user_name ||'failed, errer info is:' || vv_err_info);

end;

/

 

exec prc_drop_user('lbi_sys');

 

0 0
原创粉丝点击