?
Solved

how to kill a session in SQLPlus?

Posted on 2004-04-15
8
Medium Priority
?
5,259 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:dodowoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Accepted Solution

by:
ishando earned 80 total points
ID: 10838639
alter system kill session 'sid, serial#';

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

0
 
LVL 8

Expert Comment

by:annamalai77
ID: 10839236
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
 
LVL 2

Expert Comment

by:CallumT
ID: 10839483
you don't have to put database in restrict mode to kill a session ?
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 5

Expert Comment

by:fmonroy
ID: 10839565
no
0
 
LVL 2

Expert Comment

by:n4nazim
ID: 10839585
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
 
LVL 1

Expert Comment

by:darshan6
ID: 10859825
hi,

n4nazim has given the right method,
u can follow that

regards
sudarshan
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question