Skip to content

View and kill sessions in Oracle

View active and inactive sessions

select
  sid||','||serial#,
  status,
  username,
  schemaname,
  machine,
  program,
  logon_time
from v$session
--where schemaname = 'SCHEMA_NAME'
--where lower(machine) like lower('computername%')
;

Kill individual session

alter system kill session 'sid,serial#' immediate;

Kill all sessions associated with particular schema

begin
  for s in (select sid,serial# from v$session where schemaname = 'SCHEMA-NAME')
  loop
    execute immediate 'alter system kill session '''
        || s.sid  || ',' || s.serial# || ''' immediate';
  end loop;
end;