how to kill a session in SQLPlus?

hi experts,

I want to put the database in restricted mode and kill then kill user session. How do i kill a user session in SqlPlus?

thanks.
dodowomanAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ishandoConnect With a Mentor Commented:
alter system kill session 'sid, serial#';

the values for sid and serial# for the session can be found on the v$session view.

0
 
annamalai77Commented:
hi there


what ishando has given is right

alter system kill session 'sid,serial';

note sid and serial should come in single quotes

eg. alter system kill session '12,24';

where sid and serail can be found in v$session;

regards
annamalai
0
 
CallumTCommented:
you don't have to put database in restrict mode to kill a session ?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fmonroyCommented:
no
0
 
n4nazimCommented:
Hi,

Killing Oracle Sessions
1/ The SQLPlus Approach
2/ The NT Approach
3/ The UNIX Approach

===============================================================
1/ The SQLPlus Approach
Sessions can be killed from within oracle using the ALTER SYSTEM KILL SESSION syntax.

First identify the offending session as follows:

SELECT s.sid,
       s.serial#,
       s.osuser,
       s.program
FROM   v$session s;
 
       SID    SERIAL# OSUSER                         PROGRAM
---------- ---------- ------------------------------ ---------------
         1          1 SYSTEM                         ORACLE.EXE
         2          1 SYSTEM                         ORACLE.EXE
         3          1 SYSTEM                         ORACLE.EXE
         4          1 SYSTEM                         ORACLE.EXE
         5          1 SYSTEM                         ORACLE.EXE
         6          1 SYSTEM                         ORACLE.EXE
        20         60 SYSTEM                         DBSNMP.EXE
        43      11215 USER1                          SQLPLUSW.EXE
        33       5337 USER2                          SQLPLUSW.EXE
The SID and SERIAL# values of the relevant session can then be substituted into the following statement:

  SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';
In some situations the Oracle.exe is not able to kill the session immediately. In these cases the session will be "marked for kill". It will then be killed as soon as possible. If the marked session persists for some time you may consider killing the process at the operating system level.

===============================================================

2/ The NT Approach
To kill the session via the NT operating system, first identify the session as follows:

SELECT s.sid,
       p.spid,
       s.osuser,
       s.program
FROM   v$process p,
       v$session s
WHERE  p.addr = s.paddr;
 
       SID SPID      OSUSER                         PROGRAM
---------- --------- ------------------------------ ---------------
         1 310       SYSTEM                         ORACLE.EXE
         2 300       SYSTEM                         ORACLE.EXE
         3 309       SYSTEM                         ORACLE.EXE
         4 299       SYSTEM                         ORACLE.EXE
         5 302       SYSTEM                         ORACLE.EXE
         6 350       SYSTEM                         ORACLE.EXE
        20 412       SYSTEM                         DBSNMP.EXE
        43 410       USER1                          SQLPLUSW.EXE
        33 364       USER2                          SQLPLUSW.EXE
The SID and SPID values of the relevant session can then be substituted into the following command issued from the command line:

  C:> orakill sid spid
The session thread should be killed immediately and all resources released.

===============================================================
3/ The UNIX Approach
To kill the session via the UNIX operating system, first identify the session in the same way as the NT approach, then substitute the relevant SPID into the following command:

  % kill -9 spid
If in doubt check that the SPID matches the UNIX PROCESSID shown using:

  % ps -ef | grep ora
The session thread should be killed immediately and all resources released.


HTH
Rgds,
Nazim M
0
 
darshan6Commented:
hi,

n4nazim has given the right method,
u can follow that

regards
sudarshan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.