Last active
May 8, 2020 15:15
-
-
Save nuBacuk/8c4b3504713a2722121a38e74c3c08b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sqlplus system/oracle <<+EOF | |
| DECLARE | |
| CURSOR get_session IS SELECT sid,serial# FROM v\$session WHERE username = 'FASTGATE'; | |
| BEGIN | |
| FOR loop_session IN get_session | |
| LOOP | |
| dbms_output.Put_line(loop_session.sid); | |
| dbms_output.Put_line(loop_session.serial#); | |
| EXECUTE IMMEDIATE 'alter system kill session ''' || loop_session.sid || ',' || loop_session.serial# || ''''; | |
| END LOOP; | |
| END; | |
| +EOF | |
| sqlplus -S system/oracle << EOF | |
| SELECT username,osuser,status FROM V$SESSION WHERE username IS NOT NULL ORDER BY username,osuser,status; | |
| EOF | |
| sqlplus system/oracle << EOF | |
| 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 = SYSTEM | |
| 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; | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment