SQL>
SQL> select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';
SID SERIAL# USER# USERNAME SCHEMANAME SCHEMA# STATUS PROCESS OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------
10 4827 0 SYS SYS 0 INACTIVE 23017 oracle
209 33035 0 SYS SYS 0 ACTIVE 13138 oracle
226 5355 0 SYS TRACK_OWNER 78 KILLED 8499 oracle
SQL> select s.username,s.sid,s.serial#,p.spid,s.lockwait,s.logon_time
from v$session s, v$process p
where s.paddr = p.addr and s.USERNAME='SYS'; 2 3
USERNAME SID SERIAL# SPID LOCKWAIT LOGON_TIME
-------------------- ---------- ---------- ------------------------ ---------------- ------------------
SYS 226 5355 8500 24-FEB-16
SYS 10 4827 23018 25-FEB-16
SYS 209 33035 13139 25-FEB-16
SQL> !ps -aef|grep 8499
oracle 8499 8213 0 Feb24 ? 00:00:00 sqlplus as sysdba
oracle 8500 8499 0 Feb24 ? 00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14627 13138 0 13:25 pts/8 00:00:00 /bin/ksh -c ps -aef|grep 8499
oracle 14629 14627 0 13:25 pts/8 00:00:00 grep 8499
SQL> !ps -aef|grep 8500
oracle 8500 8499 0 Feb24 ? 00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14631 13138 0 13:25 pts/8 00:00:00 /bin/ksh -c ps -aef|grep 8500
oracle 14633 14631 0 13:25 pts/8 00:00:00 grep 8500
oracle 32079 8500 0 Feb24 ? 00:00:02 /u001/app/oracle/product/11.2.0.4/ctx/bin/ctxhx /tmp/drgibUskeUq /tmp/drgitee7wti ASCII8 utf8 H NOMETA 120 HEURISTIC FORMAT NOPDFROTATE /tmp/drgitmp4I7029 ENCRYPTED
SQL> !kill -9 8500 8499
SQL> !kill -9 32079
SQL> !kill -9 23018 23017
SQL> exit
.
.
.
.
SQL> select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';
SID SERIAL# USER# USERNAME SCHEMANAME SCHEMA# STATUS PROCESS OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------
209 33039 0 SYS SYS 0 ACTIVE 15044 oracle
SQL>
So, now as you can see there is no KILLED/INACTIVE Session. Please use below Sql Queries:
1)To Find KILLED/INACTIVE Session Process to kill use PPID & PID Column "kill -9 31105 31103"
col username format a20
col SCHEMANAME format a20
col status format a20
col OSUSER format a20
col PPID format a10
col PID format a10
select s.OSUSER,s.username,s.SCHEMANAME,s.sid,s.serial#,p.spid as PPID,s.process as PID,s.logon_time,s.STATUS
from v$session s, v$process p
where s.paddr = p.addr and s.USERNAME='SYS';
OSUSER USERNAME SCHEMANAME SID SERIAL# PPID PID LOGON_TIME STATUS
-------------------- -------------------- -------------------- ---------- ---------- ---------- ---------- ------------------ --------------------
oracle SYS SYS 6 45904 31105 31103 26-FEB-16 ACTIVE
SQL>
2)To Generate oracle statemt to kill session.
select 'alter system kill session '''||SID||','||SERIAL#||''' immediate;' from v$session where username='USER_NAME';
SQL> select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';
SID SERIAL# USER# USERNAME SCHEMANAME SCHEMA# STATUS PROCESS OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------
10 4827 0 SYS SYS 0 INACTIVE 23017 oracle
209 33035 0 SYS SYS 0 ACTIVE 13138 oracle
226 5355 0 SYS TRACK_OWNER 78 KILLED 8499 oracle
SQL> select s.username,s.sid,s.serial#,p.spid,s.lockwait,s.logon_time
from v$session s, v$process p
where s.paddr = p.addr and s.USERNAME='SYS'; 2 3
USERNAME SID SERIAL# SPID LOCKWAIT LOGON_TIME
-------------------- ---------- ---------- ------------------------ ---------------- ------------------
SYS 226 5355 8500 24-FEB-16
SYS 10 4827 23018 25-FEB-16
SYS 209 33035 13139 25-FEB-16
SQL> !ps -aef|grep 8499
oracle 8499 8213 0 Feb24 ? 00:00:00 sqlplus as sysdba
oracle 8500 8499 0 Feb24 ? 00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14627 13138 0 13:25 pts/8 00:00:00 /bin/ksh -c ps -aef|grep 8499
oracle 14629 14627 0 13:25 pts/8 00:00:00 grep 8499
SQL> !ps -aef|grep 8500
oracle 8500 8499 0 Feb24 ? 00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14631 13138 0 13:25 pts/8 00:00:00 /bin/ksh -c ps -aef|grep 8500
oracle 14633 14631 0 13:25 pts/8 00:00:00 grep 8500
oracle 32079 8500 0 Feb24 ? 00:00:02 /u001/app/oracle/product/11.2.0.4/ctx/bin/ctxhx /tmp/drgibUskeUq /tmp/drgitee7wti ASCII8 utf8 H NOMETA 120 HEURISTIC FORMAT NOPDFROTATE /tmp/drgitmp4I7029 ENCRYPTED
SQL> !kill -9 8500 8499
SQL> !kill -9 32079
SQL> !kill -9 23018 23017
SQL> exit
.
.
.
.
SQL> select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';
SID SERIAL# USER# USERNAME SCHEMANAME SCHEMA# STATUS PROCESS OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------
209 33039 0 SYS SYS 0 ACTIVE 15044 oracle
SQL>
So, now as you can see there is no KILLED/INACTIVE Session. Please use below Sql Queries:
1)To Find KILLED/INACTIVE Session Process to kill use PPID & PID Column "kill -9 31105 31103"
col username format a20
col SCHEMANAME format a20
col status format a20
col OSUSER format a20
col PPID format a10
col PID format a10
select s.OSUSER,s.username,s.SCHEMANAME,s.sid,s.serial#,p.spid as PPID,s.process as PID,s.logon_time,s.STATUS
from v$session s, v$process p
where s.paddr = p.addr and s.USERNAME='SYS';
OSUSER USERNAME SCHEMANAME SID SERIAL# PPID PID LOGON_TIME STATUS
-------------------- -------------------- -------------------- ---------- ---------- ---------- ---------- ------------------ --------------------
oracle SYS SYS 6 45904 31105 31103 26-FEB-16 ACTIVE
SQL>
2)To Generate oracle statemt to kill session.
select 'alter system kill session '''||SID||','||SERIAL#||''' immediate;' from v$session where username='USER_NAME';