Kill all sessions of a special user

Hi all,
I'm not very familar with PL/SQL but I think this will help my on my "issue".
Sometimes I need to kill all current sessions (most times 36 sessions) of a single database user.
All sessions have a different sid and serial# and manually executing "alter system kill session 'xxx,yyyy' isn't really funny.
Im thinking of a small PL/SQL script which receives the dbuser name as parameter and then killing all sessions of the user.
Could please anyone give ma a hint or a short example on this??
Many Thanks
Joerg
Edited by: Joerg Lang on 22.06.2009 12:38

Hey Hoek,
thanks...
granting "alter system" to my user, by my self :D, let the procedure run without any errors...
Strange thing and good to know...
Ok, but now I'm still having the issue when using the "username" as parameter of the procedure.
create or replace procedure kill_session(user in varchar2)
is
begin
for sessions in ( select sid, serial#
                    from   v$session
                    where  username = 'user_to_kill')
  loop
    execute immediate 'alter system kill session '''||sessions.sid||','||sessions.serial#||'''';
  end loop;
end;works fine and all sessions are killed.
create or replace procedure kill_session(user in varchar2)
is
begin
for sessions in ( select sid, serial#
                    from   v$session
                    where  username = '||user||')
  loop
    execute immediate 'alter system kill session '''||sessions.sid||','||sessions.serial#||'''';
  end loop;
end;works not, but also now errors ar shown..
any Idea?

Similar Messages

  • Killing all sessions at once who are locking the objects

    Hello all,
    i am working in 9i Oracle RDBMS on AIX IBM OS
    most of the time we face locking issue and there comes more then different 50 sessions which locking different tables.
    here is my script to find out what sessions are locking what tables.
    set lines 200
    set pages 50000
    col SID for 99999
    col SERIAL# for 999999
    col username format a12
    col sql format a55
    col event format a50
    col program format a40
    col MINS for 9999
    col ID1 for 999999
    col object_name for a35
    col locktype for a8;
    select  /*+ ORDERED */ s.sid,s.serial#,s.status,round(s.last_call_et/60) MINS,s.program,l.ID1,d.object_name,d.object_type,l.type as locktype
    from v$lock l,v$session s, dba_objects d
    where l.sid = s.sid
    and l.ID1 = d.object_id
    and s.username = 'MULDMS'
    and last_call_et > 120 and l.type <> 'TX' order by s.status,MINS,l.ID1,l.type; and the out put it gives something like
      SID SERIAL# STATUS    MINS PROGRAM                                      ID1 OBJECT_NAME                         OBJECT_TYPE        LOCKTY
    8981    1069 ACTIVE       2 frmweb@Appsdms31 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1642     512 ACTIVE      15 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
      699    1787 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1754    1582 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                      TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               28846 AM_DOCS                             TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    3521     717 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                     TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                   TABLE              TM
    9131    1002 INACTIVE     2 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    4887    1040 INACTIVE     2 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
      151    1982 INACTIVE     2 [email protected] (TNS V1-V3)     80224 RD_ENQEXD                           TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    29228 GM_VIN                              TABLE              TM
    5364    1149 INACTIVE     3 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    9934     789 INACTIVE     3 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
    7511    1092 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    3595    1104 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      945     670 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TMand then i have to kill the session one by one . thaat is a tedious task to do.
    i want to modify this script which will give me all the kill statement and i just have to run it
    can someone help me in this regard as i am weak in sql/plsql
    thanks and many thanks

    >
    i want to modify this script which will give me all the kill statement and i just have to run it
    >
    Karthick's script will 'kill' the sessions but before you use that script you may want to read the docs about the KILL and DISCONNECT clauses.
    See the DISCONNECT SESSION and KILL SESSION clauses in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm#sthref4724
    >
    DISCONNECT SESSION Clause
    Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever).
    The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
    KILL SESSION Clause
    The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources.
    IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.
    >
    For DISCONNECT the IMMEDIATE clause will recover the session state 'immediately'.
    Using KILL, even with the IMMEDIATE clause, you are telliing Oracle to roll back any ongoing transactions and that can take a lot of time.
    Make sure you are really doing the operation you want to do. If you want to get the locks released immediately you need to use 'DISCONNECT IMMEDIATE'.

  • Deploying an app kills all sessions on server.

    We have a problem using OC4J Standalone, where whenever you deploy an app from JDeveloper, all sessions on the server are killed, even for other apps.
    We use 9.0.3, but I have tested this in 9.0.4 with the same results. Is there a setting somewhere that effects this?
    Any help whatsoever would be appreciated.

    Hi,
    You can set persistence-path to store sessions during application deployments. This works in 9.0.4.
    http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10321/confdesc.htm#1019473
    persistence-path: Indicates where to store servlet HttpSession objects for persistence across server restarts or application redeployments. Specify a relative path, which will be relative to an OC4J temporary storage area under the application-deployments directory. There is no default value. If no value is defined, then there is no persistence of session objects across restarts or redeployments.
    thanks
    Debu

  • How to kill the session after the user exit the ADF application

    Dear all
    I have a problem
    The problem is the session still exist after the user close the application and the browser. I want to kill all sessions that is not active.
    This is my test scenario:
    1- I open IE and run my ADF application that is deployed on weblogic. http://192.168.100.17:7001/myapp/faces/login
    2- At the same time I issue this SQL command to view the sessions for user 'ADFUSER' - the "ADFUSER" is the schema user.
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER';QUERY RESULT IS
    USERNAME                       MODULE                                           STATUS
    ADFUSER                         JDBC Thin Client                                 INACTIVE3- Now the user close the browser
    4- Run the SQL again and I notice that the session still exist
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER'RESULT:
    USERNAME                       MODULE                                           STATUS
    ADFUSER                        JDBC Thin Client                                 INACTIVE5- now the user open the URL again http://192.168.100.17:7001/myapp/faces/login
    6-Run the SQL again , and I notice that the old session still exists and a new session created too.
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER'RESULT:
    USERNAME                       MODULE                                           STATUS
    ADFUSER                        JDBC Thin Client                                 INACTIVE
    ADFUSER                        JDBC Thin Client                                 INACTIVE
    2 rows selected.and every time I login to the application , a new session is open and the old session still exist
    I do not know why this happens
    I want to kill old session when the user close the application.
    These sessions are cleared only when i restart the weblogic domain.
    here is some information about my development environment:
    Jdeveloper 11.1.2.3
    WebLogic Server Version: 10.3.5.0
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    thanks in advance

    Hi,
    for performance reasons you should not use dedicated user connections to the database. Instead you use JDBC data sources (default in JDeveloper for ADF BC) that you can configure the database connection pooling for. This means that your v$session will always show a set of active session, which however are shared among users. Assuming you use ADF BC, this is what happens
    - A user requests a data bound page
    - The ADF BC checks out an AM and connects to the database using one of the database connections in the pool
    ... user work here ...
    - user exits application
    - ADF BC returns AM to pool and passivates pending user state (if application is left with dirty transaction)
    - Database connection is available in pool as soon as AM released
    This also happens between requests. Long story cut short: v$session doesn't give you a true picture
    Frank

  • Kill a session and release all locks immediatly

    Hi,
    How to kill a session and release all locks immediately.
    Thank you
    AK

    > Actually I am working on development envrionment (Not
    production) with oracle 10g DB. What heppened is that
    I needed to replace a stored DB Package, but I
    couldn't even when I am the only connected user.
    A read lock is placed on data dictionary objects when used - that prevents someone else from changing that data dictionary object and in effect pull the carpet from beneath the feet of the process using that object.
    When trying to replace a package, it will fail if another session is busy using that package.
    As for being the only user on the database and still running into this problem - there could have been a DBMS_JOB executing that package.
    > I killed all sessions, and even next day still the
    locks are there from a session I killed 1 day
    before!
    Unusual. But a killed session can take 24+ hours to rollback. A rollback is often a lot more time consuming than the elapsed run-time of the session at the time it was killed.
    Back with Oracle 8i and prior, it was not uncommon to see a killed session lingering forever until the instance was bounced. But I have not yet seen this in 10G.
    Suggest that when you run into this situation again, you monitor the killed session to determine just what it is doing (looking at its current wait states and events) - and whether it is indeed hanging and not releasing any locks that should have been released.

  • Killing Oracle Sessions

    Please ignore it. By mistakely i posted this thread here.
    Hi All,
    I want to drop one user. If i made a attempt to drop that user, I rec'd "ORA-01940: cannot drop a user that is currently connected." error. So I checked with sessions with the username. No one is using this user. But it resists some inactive sessions.
    SQL> DROP USER test cascade;
    DROP USER test cascade
    ERROR at line 1:
    ORA-01940: cannot drop a user that is currently connected
    SQL>select sid,serial#,username,status from v$session where schemaname='TEST';
    SID SERIAL# USERNAME STATUS
    131 4026 TEST INACTIVE
    143 29325 TEST INACTIVE
    SQL> alter system kill session '131,4026' immediate;
    system altered.
    SQL>alter system kill session '143,29325' immediate;
    system altered.
    SQL> alter system kill session '131,4026' immediate;
    system altered.
    SQL>alter system kill session '143,29325' immediate;
    system altered.
    SQL> alter system kill session '131,4026' immediate;
    system altered.
    SQL>alter system kill session '143,29325' immediate;
    system altered.
    SQL> alter system kill session '131,4026' immediate;
    system altered.
    SQL>alter system kill session '143,29325' immediate;
    system altered.
    Now. I checked in v$sessions,
    SQL>select sid,serial#,username,status from v$session where schemaname='TEST';
    SID SERIAL# USERNAME STATUS
    139 12982 AGILITY_QA INACTIVE
    141 54482 AGILITY_QA INACTIVE
    It shows some other inactive sessions. so i am trying to kill these 2 sessions again some inactive sessions will show.
    Please assist me to fix that problem.
    Message was edited by:
    Moorthy GS

    Try the output of the query to kill all sessions:
    select 'alter system kill session '''||sid||','||'4026''' immediate;' scr
    from v$session
    where schemaname='TEST' and status <> 'KILLED'
    Regards
    RK

  • Kill all oracle session

    Situation:
    Oracle Forms 9i application, with multiple oracle forms (MDI). When I call a new forms I use OPEN_FORM(v_cm_module, ACTIVATE, session, pl_id) so I create a new oracle session.
    Problem:
    The user open a lot of windows (oracle forms .fmx with diferent sessions each one) in the oracle forms application, when they close the browser window (X botom of the browser, mozilla, internet explorer), the session are still alive (only kill one session....the first I think).
    I know that after 15 minutes oracle kill the rest of the sessions, but if the user was editing a block (locking a record), and close the browser, the table still lock 15 minutes!!!!.
    Any sugestions:???
    Thanks

    Is it necessary to create a session for each form?
    If so you could do the following:
    in the formsweb.cfg set the seperateframe property on true; and place some JavaScript code into the htmlafterform property:
    HTMLafterForm=<script type="text/javascript"> window.moveTo(-10000, -10000); </script>
    now you have a seperate frame, the browser window gets moved to a position where you can't see it ;-). when clicking the X button in the seperate frame the current form will be closed; your MDI application is still running...if you wan't you can write a JavaBean, and get the windowlisteners of the seperate frame and replace them with your own...of course you can close the Browser by right clicking and closing it in the taskbar; but that's a thing you must live with...
    besides that I have no clue how to get rid of those sessions, as I don't you have any event you can act with when closing the Browser. But if so you could save every sid in every when-new-form-instance trigger (you can get it from v$mystat), and when this event occurs you could kill all those sessions (alter system kill session ....) ;-). but as far as I know that's not possible...
    regards
    christian

  • Looking for a script to kill all inactive sessions

    Does anyone have a script to kill all INACTIVE sessions (with EXECUTE IMMEDIATE)?

    I suggest you to specify which OS you are talking about.
    The inactive status on the V$SESSION doesn't mean the user is not doing any thing, it only means the oracle server process is not processing any thing by the time it was queried. On OLTP systems Oracle Server Processes remain INACTIVE for more than 95% of the time, so it is advisable to configure shared servers.
    If you are really concerned about idle time, then I suggest you to configure profiles.
    On the pool mechanism you should address the microsoft side, if this, as far as I understood and guessed, application server is IIS.
    I suggest you further reading on the Killing sessions script and different session status (check the sniped status) here:
    Re: session inactive ??
    Re: make a job to delete the sniped sessions
    Re: How do I put a timeout in my DataBase?
    Re: Killing Session with Locks in Linux
    ~ Madrid

  • ALLOW A USER TO KILL A SESSION WITHOUT ALTER SYSTEM PRIVILEGE.

    Hi
    I need a user to have permission to kill a session without having the ALTER SYSTEM privilege. I created a procedure on sys schema and granted the EXECUTE privilege to the user but it doesn't work, how can I do, help please.
    CREATE OR REPLACE PROCEDURE SYS.PRC_SESSION_KILLER (P_SID IN NUMBER, P_SERIAL IN NUMBER)
    AS
    BEGIN
         EXECUTE IMMEDIATE 'GRANT ALTER SYSTEM TO SYSADMIN';
         EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || P_SID || ',' || P_SERIAL || ''' IMMEDIATE';
         EXECUTE IMMEDIATE 'REVOKE ALTER SYSTEM FROM SYSADMIN';
    END;
    Thank you very much.

    Hi,
    I second everything John said.
    Are you sure the arguments are correct?
    Below is the procedure I use. You may want to run it, just to see what the error is.
    PROCEDURE     kill_internal
         s_id          IN     NUMBER,
         serial_num     IN     NUMBER,
         stat_out     OUT     VARCHAR2
    IS
         alter_handle     INTEGER;
         ex_val          INTEGER;     -- Returned by dbms_sql.execute
    BEGIN
         alter_handle := dbms_sql.open_cursor;
         dbms_sql.parse
              alter_handle,
              'ALTER SYSTEM     KILL SESSION '''     ||
                   TO_CHAR (s_id, '999990')     ||
                   ', '                    ||
                   TO_CHAR (serial_num, '999990')     ||
              dbms_sql.native
         ex_val := dbms_sql.execute (alter_handle);
         dbms_sql.close_cursor (alter_handle);
         stat_out := 'Success: '                    ||
                   TO_CHAR (s_id, '999990')     ||
                   ', '                    ||
                   TO_CHAR (serial_num, '999990');
    EXCEPTION
         WHEN OTHERS
         THEN
              stat_out := 'Failure:'          ||
                   SQLERRM;
    --          dbms_output.put_line (stat_out);
              dbms_sql.close_cursor (alter_handle);
    END     kill_internal
    ;

  • Disable fading visual effect for all session users

    Hello guys,
    someone can say me how I can disable fading visual effect on windows 2012 R2 RDS?
    All session users have these visual effect that I don't know how to disable.
    Thanks
    Andrea

    Hi,
    Thank you for posting in Windows Server Forum.
    Firstly please try to provide TP’s reply, in addition to that you can check below settings on server and see the result.
    You need to edit parts of System Properties-Performance Options as per below snap.
    Snap:
    For more information, refer beneath articles might help to solve your issue.
    1. Disable visual effects in Windows
    2. Program menus slow when accessed through Remote Desktop / Terminal Services
    Hope it helps!
    Thanks.
    Dharmesh Solanki

  • How to replicate session data at the user level?

    Hi all,
    my client has users who use laptop/tablet computers in the field with wireless connections. The application requires the users to complete long multi-page forms where the data is only submitted to the EIS layer at the end of the process. The connections regularly drop out which understandably is a cause of some grief. In addition, the users want to be able to switch to another machine in order to complete their session.
    The 'switching machine' requirement kills the idea of using persistent cookies and session replication unfortunately. So I am faced with the idea of storing the session data (keyed by user id), in serialized form, either on a stand-alone disk which is accessible by each webserver in the cluster or is the database. The problem with the database idea is the performance hit of traversing the EJB and JDBC layers.
    Can anyone suggest the best practice in this case? Or point to an article or tool that covers the problem?
    BTW, the app serves a small (<50) and stable base of authenticated users so scalability is not really an issue whereas failover is.
    Regards,
    Dave.

    > Is it possible to close a PO at the header level
    Po can be closed at Item level and not Header level. You can set Deletion Indicator and further can be archived thru SARA MM_EKKO
    or a way to deactivate the PO so that no new items can be added?
    You can activate Release strategy and Choose a Proper Release indicatory so that no new changes to be carried out.
    Else go for User Exits

  • Unable to kill a session in SM50 or SM66

    One of our developer was working on a program and there was a network failure.  When we got the network back the system shows the process is till running since 3 days. Tried to kill it from SM50 and SM66. 
    While logging in it is giving 3 options and even after selecting "Continue with this logon and end any other logons in system" its not ending that session.
    After we logon the program is running good.
    How to kill this session??
    Details of the session is given below
    No Ty. PID      Status  Reasn Start Err Sem CPU      Time   Cl. User
    3  DIA 6584     Running       No            296:36   168191 130 BYARLAGADDA
    Report / Spool action
    CL_ABAP_TABLEDESCR============CP
    Main Program
    SAPLCV110
    Action                    Table
    Waiting f.                                                                   since
    Database                         Number              Time (usec)         Recs.
    Direct Read                    14,681             519,103                 524
    Sequential Read                18,146            595171                    83
    Insert                              0                   0                   0
    Update                              0                   0                   0
    Delete                              0                   0                   0

    Why does no-one understand SAP Architecture well enough anymore, I blame bad trainers.
    Its like seeing a car driving badly all over the road and blowing up the car rather than shooting the driver.
    The WP is not the problem, it is the task in the WP that is.
    Killing a user in SM04 or a job in SM37 often works. Then I would try cancelling the program in SM50, not the work process.
    If that fails then normally it is waiting on something - often RFC. If RFC a simple removal of the connection in SMGW removes the task from the WP. In this case it looks like a rogue DB process, in this case the WP is just waiting for a response from the DB... killing the WP just gets rid of the visibility in SM50, it does not remove the problem... in fact it then would make my job of identifying why the system is running slow a lot worse.

  • Monitoring sessions invoked by a user SQL Developer

    Hello Everyone ,
    I am a DBA and lot of developers use SQL Developer for their tasks. Off late we have been facing few issues with SQL Developer.
    Developers close the working session by "alt+f4" and strangely their sessions are active in the DB's. What is the cause for this ?
    Rollback of DML statements takes hours for statements submitted by SQL Developer.
    Does OCI driver help in any way ?
    Is there any way that I can allow individual users to monitor their sessions in SQL Developer?
    Suppose a user connects with a generic application username "xyz" , can I allow the user "xyz"  to monitor sessions invoked by him and also provide him privileges to kill his/her own session.
    We are facing lot of performance issues , so help in this regard would be highly appreciated.
    Even pointing me towards appropriate documentation would do.
    Thanks in anticipation.

    1006957 wrote:
    I am a DBA and lot of developers use SQL Developer for their tasks. Off late we have been facing few issues with SQL Developer.
    Developers close the working session by "alt+f4" and strangely their sessions are active in the DB's. What is the cause for this ?
    Rollback of DML statements takes hours for statements submitted by SQL Developer.
    Does OCI driver help in any way ?
    Is there any way that I can allow individual users to monitor their sessions in SQL Developer?
    Suppose a user connects with a generic application username "xyz" , can I allow the user "xyz"  to monitor sessions invoked by him and also provide him privileges to kill his/her own session.
    We are facing lot of performance issues , so help in this regard would be highly appreciated.
    Even pointing me towards appropriate documentation would do.
    Once the DB begins work on a task it will continue that work until: 1) the work is complete, 2) an exception occurs or 3) it discovers that the client is no longer there.
    If you begin a transaction (complex query, sorts, etc) that is lengthy it may be a while before the DB even tries to communicate with the client. Then all of that work must be rolled back and the rollback (e.g. for an update or delete) can take much longer than the query took to begin with. That is just the way Oracle works.
    If a user connects as "xyz" then the only 'sessions invoked by him' are that ONE session. Any other user might also create a session by connecting as "xyz"; Oracle has no way of knowing if ALL sessions connecting as "xyz" belong to the same person or not.
    The ALTER SYSTEM privilege must be granted to allow someone to 'kill his/her own session' but that privilege would allow them to kill any other session, including system sessions.
    You could write a procedure to try to control the privilige, as in the following thread, but that also has risks:
    https://forums.oracle.com/thread/256935
    It is a DBA responsibility to control sessions, not the developers. You should NOT give this ability to the developers IMHO. If your developers are abusing your system it indicates that they need more training in how to prevent runaway queries. A common cause of the problem you describe is when a developer submits a query and then thinks they can just cancel it and start over and they DO NOT UNDERSTAND the first statement I made above: Oracle will keep working.
    The proper solution to your problem is to begin logging your developer's requests for session termination so that you can properly monitor the problem and detect developers that need additional instruction or mentoring to keep the problem from happening. Although anyone, even experts, can accidentally let a query get out of control, your problem doesn't occur very frequently for experienced developers.
    The DISCONNECT option only politely requests Oracle to terminate the session so it make take considerable time to clean everything up.
    If you really need to terminate the session you need to use DISCONNECT IMMEDIATE. See the disconnect session clause of alter system in the sql language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm#sthref4725
    {quote}
    DISCONNECT SESSION Clause
    Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever). To use this clause, your instance must have the database open. You must identify the session with both of the following values from the V$SESSION view:
      For integer1, specify the value of the SID column.
      For integer2, specify the value of the SERIAL# column.
    If system parameters are appropriately configured, then application failover will take effect.
      The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected. If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
      The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.  If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
      If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions, then this clause has the same effect as described for KILL SESSION IMMEDIATE.
    {quote}

  • AUTOMATICALLY KILL  INACTIVE SESSIONS

    Hi all. we are using oracle 8.1.6 on windows-2000 with 2gb ram. we facing
    ora-12500 listner failed to start a dedicated server.
    error and for this we made certain changes. we also added a parameter in sqlnet.ora at server side sqlnet.expire_time=10.. for automatically killing inactive sessions but it did not helped and many sessions remain in v$session. i wana know what should we do to kill inactive sessions. because i think when the sessions reach more than 300 then we face problem of listner failed. thanks for u'r valueable comments in advance as well.
    best wishes
    muhammad mohsin chattha

    Hi Nicolas, what you say is correct, but, unless the user try to do something (and receives an error),
    those sessions will show up as SNIPED in V$SESSION, and never go away.
    We can create a procedure to kill these sessions, something like this :  1  CREATE OR REPLACE PROCEDURE Kill_Sessions   IS
      2      Stmt           VARCHAR2(200);
      3      V_Sid          VARCHAR2(30);
      4      V_Serial       VARCHAR2(30);
      5      V_Username     VARCHAR2(30);
      6      CURSOR pri IS
      7      SELECT Sid, Serial#, Username
      8      FROM V$Session
      9      WHERE Username Is Not Null
    10      And Username not like 'SYS%'
    11      And Status = 'SNIPED';
    12  BEGIN
    13      FOR usr in pri LOOP
    14      V_Sid     := usr.Sid;
    15      V_Serial  := Usr.Serial#;
    16      Stmt      := 'ALTER SYSTEM KILL SESSION ''' || V_Sid || ',' || V_Serial || '''';
    17      Execute Immediate(Stmt);
    18      END LOOP;
    19* END;
    20  /  and execute it every minute (change 1440 to change the frequence) :SQL> Declare
      2     Out_Var Int;
      3  Begin
      4     Dbms_Job.Submit(Out_Var,
      5     'Kill_Sessions;',
      6     Sysdate,
      7     'Sysdate+1/1440' );
      8* End;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>

  • How to find killed form session

    Hi All,
    I have killed a form session in production.
    is there any way to find the killed form session.
    web and forms or on one server and concurrent managers or on other server
    and also can we find out how many users have connected to applications and database .
    our application version is 11.5.10.2 and database version is 9.2.0.8.
    Thanks,
    sandeep.

    I have killed a form session in production.
    is there any way to find the killed form session.If the session is no longer marked as killed then you cannot find it.
    http://forums.oracle.com/forums/search.jspa?threadID=&q=Inactive+AND+Sessions&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    and also can we find out how many users have connected to applications and database .http://forums.oracle.com/forums/search.jspa?threadID=&q=Users+Connected&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

Maybe you are looking for