如何让别人,非DBA也可以kill session
-
create or replace procedure kill_session( p_sid in number, p_serial# in number )
-
as
-
begin
-
for x in ( select *
-
from v$session
-
where username = USER
-
and sid = p_sid
-
and serial# = p_serial# )
-
loop
-
execute immediate 'alter system kill session ''' ||
-
p_sid || ',' || p_serial# || '''';
-
dbms_output.put_line( 'Alter session done' );
-
end loop;
-
end;
然后grant execute on procudure whomever. Now, anyone can kill a session owned by the same
username as they are logged in as (eg: their sessions)
.
还可以kill 指定 instance上面的session
-
sys%ORA11GR1> select inst_id, sid, serial#, username from gv$session where username is not null;
-
-
INST_ID SID SERIAL# USERNAME
-
---------- ---------- ---------- --------------------
-
1 126 3565 OPS$TKYTE
-
1 144 6999 SYS
-
-
2 rows selected.
-
-
sys%ORA11GR1> alter system kill session '126,3565,@1';
-
-
System altered.
阅读(728) | 评论(0) | 转发(0) |