Solved

how to kill a session in SQLPlus?

Posted on 2004-04-15
8
5,150 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 20 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

733 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