Answers for "oracle kill session by username"

SQL
6

oracle kill session by username

-- Get ORACLE Session IDs (SID and SERIAL#)
SELECT SID, SERIAL#, STATUS, SERVER FROM V$SESSION WHERE USERNAME = '<username>';
-- Kill session (and wait for rollback if any...)
ALTER SYSTEM KILL SESSION 'SID,SERIAL#' IMMEDIATE;
Posted by: Guest on April-21-2021
2

oracle kill job by sid

-- Get Job session IDs
SELECT jr.JOB, s.USERNAME, s.SID, s.SERIAL#, p.SPID, s.LOCKWAIT, s.LOGON_TIME
FROM DBA_JOBS_RUNNING jr, V$SESSION s, V$PROCESS p
WHERE jr.SID = s.SID AND s.PADDR = p.ADDR ORDER BY jr.JOB;
-- Or simply a session
SELECT SID, SERIAL#, STATUS, SERVER FROM V$SESSION WHERE USERNAME = '<username>';
-- Kill session with IDs and wait for rollback if any...
ALTER SYSTEM KILL SESSION 'SID,SERIAL#' IMMEDIATE;
-- To simply stop job without killing session:
BEGIN
    DBMS_SCHEDULER.STOP_JOB(JOB_NAME => 'scheme.job_name', FORCE => TRUE);
END;
Posted by: Guest on April-21-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language