Skip to content

Instantly share code, notes, and snippets.

@nuBacuk
Last active May 8, 2020 15:15
Show Gist options
  • Select an option

  • Save nuBacuk/8c4b3504713a2722121a38e74c3c08b3 to your computer and use it in GitHub Desktop.

Select an option

Save nuBacuk/8c4b3504713a2722121a38e74c3c08b3 to your computer and use it in GitHub Desktop.
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