Kill session permission without alter system permission?

Syntax to kill session is
ALTER SYSTEM KILL SESSION 'session info';
Is there a way to allow a user to kill his/her own session without granting rights to SYSTEM? I don't want anyone to be able to drop the database, but they need to be able to kill their own session. I've looked everywhere...
Thanks in advance!

Yes, assuming you are using standard definer's rights stored procedures. Only if you specify AUTHID CURRENT_USER when creating the stored procedure will you get an invoker's rights stored procedure, which would run with the privileges of the caller, not of the definer.
Justin

Similar Messages

  • 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
    ;

  • Flush Shared Pool without Alter System Priv

    I am trying to device a way to flush the shared pool by a user who doesn't have ALTER SYSTEM priv. I tried creating a stored proc in user's schema who has DBA role
    with the following:
    execute immediate 'alter system flush shared_pool';
    and then granted execute on this to a normal user without explicit alter system priv, but the execution fails and seems that I need to grant alter system explicitly to this user. Is there any other workaorund for this?
    Thank You
    Kevin

    it works for me! V10.2.0.4 too.
    SQL> set time on
    12:11:24 SQL> @privs
    12:11:28 SQL> SET TERM ON ECHO ON
    12:11:28 SQL> SET SERVEROUTPUT ON
    12:11:28 SQL> CREATE USER PTST IDENTIFIED BY PTST DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON users TEMPORARY TABLESPACE TEMP;
    User created.
    12:11:28 SQL> grant create session to ptst;
    Grant succeeded.
    12:11:28 SQL> grant alter system to dbadmin;
    Grant succeeded.
    12:11:28 SQL> connect dbadmin/admindb
    Connected.
    12:11:28 SQL> set term on echo on
    12:11:28 SQL> create or replace procedure flush_pool
    12:11:28   2  as
    12:11:28   3  begin
    12:11:28   4  execute immediate 'alter system flush shared_pool';
    12:11:28   5  end flush_pool;
    12:11:28   6  /
    Procedure created.
    12:11:28 SQL> grant execute on flush_pool to ptst;
    Grant succeeded.
    12:11:28 SQL> connect ptst/ptst
    Connected.
    12:11:28 SQL> SET TERM ON ECHO ON
    12:11:28 SQL> execute dbadmin.flush_pool;
    PL/SQL procedure successfully completed.
    12:11:29 SQL> connect / as sysdba
    Connected.
    12:11:29 SQL> drop user ptst;
    User dropped.

  • Urgent-how to run 'alter system kill session 'sid, serial#' in form 6i ?

    I want to write a procedure in Form 6i so that user can kill the session by herself.
    I know kill session sql is 'alter system kill session 'sid, serial#'', however, I fould that I can only run it it sql plus screen, how can I run it in Form or in Stored procedure?
    Urgent....Please!

    try using Forms_ddl('alter system......'); in the forms. it will execute the dml statements in the form.
    zaibi.

  • Alter system kill session 'sid, serial#'

    Hi,
    how can I do
    alter system kill session 'sid, serial#'
    while sid and serial# should come from :
    select sid, serial# from v$session where
    Explanation :
    I want :something like :
    alter system kill session 'select sid, serial# from v$session where '
    Do you know a solution?
    Many thanks before.

    In SQL*Plus you could issue:
    SQL> select
      2     'alter system kill session '''||TO_CHAR(sid)||','||to_char(serial#)||''';'
      3  from
      4     v$session
      5  where
      6     username=user
      7  /
    'ALTERSYSTEMKILLSESSION'''||TO_CHAR(SID)||','||TO_CHAR(SERIAL#)||''';'
    alter system kill session '421,4259';
    alter system kill session '424,103';Then copy + run the output.
    HTH
    David

  • Ora-01940 in the old versione there was the possibility to kill session

    I have tried to drp a user that remain connect.
    I receive the error : ORA-01940.
    I USE DB 10G
    in release 9 the was the possibility (with enterprise manager) to kill all the session of the user.
    In DB 10 where is this function ??
    I have try to foun in the menu but i have not found it ( i cannot shutdown the database because there is a lot of user that are connect)
    Than'ks

    Don't know of OEM, but if you want to kill all user's sessions, then that's very easy from Sql*Plus (as DBA or SYSDBA)
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> get killsess
      1  set pages 0
      2  set feed off
      3  set veri off
      4  accept USR prompt 'Enter Username : '
      5  spool kill_sessions.sql
      6  select 'set feed on' from dual;
      7  select 'alter system kill session '||chr(39)||sid||','||serial#||chr(39)||';'
      8  from v$session
      9  where username = upper('&USR')
    10  /
    11* spool off
    SQL> @killsess
    Enter Username : scott
    set feed on
    alter system kill session '244,1087';
    alter system kill session '253,768';
    SQL> @kill_sessions
    System altered.
    System altered.
    SQL>

  • Kill session privillege

    Hi there
    I want to know whether there any privilege to kill session, because i want to give this privilege to my developer team instead of DBA role.
    Database : oracle 10g 10.2.0.3
    Regards
    Rabi

    you cant kill your own session. Using alter system you(developer those who have alter system privilege) can kill other sessions.
    eg:-
    SQL> create user test identified by test;
    User created.
    SQL> grant connect,resource to test;
    Grant succeeded.
    SQL> GRANT ALTER SYSTEM TO TEST;
    Grant succeeded.
    SQL> grant select on v_$session to TEST;
    Grant succeeded.
    SQL> conn test/test;
    Connected.
    SQL> select sid,serial# from v$session where username='TEST';
           SID    SERIAL#
           521      37794
    SQL> ALTER SYSTEM KILL SESSION '521,37794';
    ALTER SYSTEM KILL SESSION '521,37794'
    ERROR at line 1:
    ORA-00027: cannot kill current sessionhad better, refer the link for more information.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_2013.htm
    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. To use this clause, your instance must have the database open, and your session and the session to be terminated must be on the same instance. 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 the session is performing some activity that must be completed, such as waiting for a reply from a remote database or rolling back a transaction, then Oracle Database waits for this activity to complete, marks the session as terminated, and then returns control to you. If the waiting lasts a minute, then Oracle Database marks the session to be terminated and returns control to you with a message that the session is marked to be terminated. The PMON background process then marks the session as terminated when the activity is complete.
    Whether or not the session has an ongoing transaction, Oracle Database does not recover the entire session state until the session user issues a request to the session and receives a message that the session has been terminated.

  • Kill session manually

    Hi,
    I have a client application use C# to access oracle database. But when the client log out his session on db still exists.. So is there anyway to write a method to kill the session manually.
    I mean when the user press the log out button...
    thanks in advance.....

    ALTER SYSTEM KILL SESSION '7,15';since you can't kill your own session, you have to connect again (one more connection to the DB) to kill this other sesion. Then, again, you have a problem since you have this new connection that you need to kill.
    A close call on the connection is all what is required.
    SQL> alter system kill session '21,6172' ;
    alter system kill session '21,6172'
    ERROR at line 1:
    ORA-00027: cannot kill current session
    SQL>Message was edited by:
    Kamal Kishore

  • Trace File Created Upon Execution of "alter system kill session sid, serial# immediate;"

    A problem within a third-party application is causing it to create and abandon Oracle sessions. At times three hundred or more abandoned sessions accumulated in the instance. The software company is working on the problem. Oracle's background processes will get rid of those sessions after several hours, but at times there were so many they caused the server to start using paging space. We wrote a SQL*Plus script to identify the abandoned sessions and kill them with command "alter system kill session <sid, serial#> immediate;". We automated the execution of the script a week ago. Today I noticed that in my udump directory an Oracle trace file has been created each time our script kills a session. A single trace file is created regardless of how many sessions are killed. No errors appear in the trace file.
    Is the creation of these trace files an indication that problems have occurred or are they there for information only?
    Since I know how and why the sessions are being killed, is it safe to ignore the trace files?
    Thank you,
    Bill

    The OS is AIX 5.2. The database server is 10.2.0.2. We are in the processing of upgrading to AIX 7.1 and database server 11.2.0.3.6.
    The script does not enable tracing for the SQL*Plus session.
    Below is the alert log message from a session killed at 11:22, and the corresponding trace file created at that same time:
    From alert_<sid>.log: 
    Wed Jul 31 11:22:01 2013
    Immediate Kill Session#: 1119, Serial#: 59885
    Immediate Kill Session: sess: 70000014dc4a7e0 OS pid: 267254
    /u02/admin/EXPRESS/udump $ ls -l express_ora_113358.trc
    -rw-r----- 1 oracle dba 2276 Jul 31 11:22 express_ora_113358.trc
    /u02/admin/EXPRESS/udump $ pg express_ora_113358.trc
    Dump file /u02/admin/EXPRESS/udump/express_ora_113358.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    ORACLE_HOME = /u01/app/oracle/product/10.2.0
    System name: AIX
    Node name: navis
    Release: 2
    Version: 5
    Machine: 0005CD8C4C00
    Instance name: EXPRESS
    Redo thread mounted by this instance: 1
    Oracle process number: 225
    Unix process pid: 113358, image: oracleEXPRESS@navis
    *** ACTION NAME:() 2013-07-31 11:22:01.181
    *** MODULE NAME:(SQL*Plus) 2013-07-31 11:22:01.181
    *** SERVICE NAME:(EXPRESS.WORLD) 2013-07-31 11:22:01.181
    *** SESSION ID:(1723.61000) 2013-07-31 11:22:01.181
    SO: 70000014d44d278, type: 2, owner: 0, flag: INIT/-/-/0x00
    (process) Oracle pid=463, calls cur/top: 0/700000139166298, flag: (0) -
    int error: 0, call error: 0, sess error: 0, txn error 0
    (post info) last post received: 108 0 4
    last post received-location: kslpsr
    last process to post me: 70000014d36c398 1 6
    last post sent: 0 0 24
    last post sent-location: ksasnd
    last process posted by me: 70000014d36c398 1 6
    (latch info) wait_event=0 bits=0
    Process Group: DEFAULT, pseudo proc: 70000014d6aec00
    O/S info: user: oracle, term: UNKNOWN, ospid: 267254
    OSD pid info: Unix process pid: 267254, image: oracleEXPRESS@navis
    Short stack dump:
    ksdxfstk+002c<-ksdxcb+04e4<-sspuser+0074<-00004CB0<-nttrd+0120<-nsprecv+0750<-ns
    rdr+0114<-nsdo+1714<-nsbrecv+0040<-nioqrc+04a8<-opikndf2+0688<-opitsk+088c<-opii
    no+0990<-opiodr+0adc<-opidrv+0474<-sou2o+0090<-opimai_real+01bc<-main+0098<-__st
    art+0090
    Dump of memory from 0x070000014D2CC3B0 to 0x070000014D2CC5B8
    70000014D2CC3B0 00000004 00000000 07000001 39DA8D48 [............9..H]
    70000014D2CC3C0 00000010 0003139D 07000001 39166298 [............9.b.]
    70000014D2CC3D0 00000003 0003139D 07000001 4C73D508 [............Ls..]
    70000014D2CC3E0 0000000B 0003139D 07000001 4DC4A7E0 [............M...]
    70000014D2CC3F0 00000004 00031291 00000000 00000000 [................]
    70000014D2CC400 00000000 00000000 00000000 00000000 [................]
    Repeat 26 times
    70000014D2CC5B0 00000000 00000000 [........]
    Thanks,
    Bill

  • Can't kill session with "Alter system kill session"?

    I'm using 9iR2.
    After I check the v$session table:
    SQL> select sid, serial# from v$session where username='XMLDEMO';
    SID SERIAL#
    18 19155
    I issue the command:
    SQL> alter system kill session '18,19155' immediate;
    System altered.
    But after this, I still can find this session:
    SQL> select sid, serial# from v$session where username='XMLDEMO';
    SID SERIAL#
    18 19155
    Can anyone tell me why? Did I miss something?
    Any help will be appreciated.
    Jinyu

    keep issuing that query and notice if the serial number starts to change..if it does it is reflecting pmon cleaning up the sessions, when pmon finishes his work
    the sesison will disappear from v$session.
    steve
    I'm using 9iR2.
    After I check the v$session table:
    SQL> select sid, serial# from v$session where username='XMLDEMO';
    SID SERIAL#
    18 19155
    I issue the command:
    SQL> alter system kill session '18,19155' immediate;
    System altered.
    But after this, I still can find this session:
    SQL> select sid, serial# from v$session where username='XMLDEMO';
    SID SERIAL#
    18 19155
    Can anyone tell me why? Did I miss something?
    Any help will be appreciated.
    Jinyu

  • How to "kill" AWT Event Queue thread without using System.exit()?

    When I run my program and the first GUI window is displayed a new thread is created - "AWT-Event Queue". When my program finishes, this thread stays alive and I think it causes some problems I have experienced lately.
    Is there any possibility to "kill" this thread without using System.exit() (I can't use it for some specific reasons)

    All threads are kept alive by the JVM session. When you use System.exit(int) you kill the current session, thus killing all threads. I'm not sure, though...
    What you could do, to make sure all threads die, is to make ever thread you start member of a thread group. When you want to exit you app, you kill all the threads in the thread group before exit.
    A small example:
    //Should be declared somewhere
    static ThreadGroup threadGroup = new ThreadGroup("My ThreadGroup");
    class MyClass extends Thread {
    super(threadGroup, "MyThread");
    Thread thread = new Thread(threadGroup, "MySecondThread");
    void exit() {
    //Deprecated, seek alternative
    threadGroup.stop();
    System.exit(0);
    }

  • Permissions for package owner for kill session?

    What permissions does a package owner need to execute immediate 'alter system kill session' within a package?

    Are you sure? It works for me on 10.2.0.1 (32 bit Windows)
    SYS @ jcave102 Local> drop user bob cascade;
    User dropped.
    Elapsed: 00:00:11.25
    SYS @ jcave102 Local> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.10
    SYS @ jcave102 Local> create user bob identified by bob default tablespace users;
    User created.
    Elapsed: 00:00:00.07
    SYS @ jcave102 Local> grant create session, create procedure, alter system to bob;
    Grant succeeded.
    Elapsed: 00:00:00.01
    SYS @ jcave102 Local> conn bob/bob
    Connected.
      1  create or replace procedure kill_session( p_sid in number, p_serial# in number )
      2  as
      3  begin
      4    execute immediate 'alter system kill session ''' || p_sid || ',' || p_serial# || '''';
      5* end;
    BOB @ jcave102  > /
    Procedure created.
    Elapsed: 00:00:00.57Now, find a session to kill (using a user other than BOB who doesn't have permission to view the V$SESSION table) and call the procedure
    BOB @ jcave102 Local> exec kill_session( 144, 115 );
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00Justin

  • Need help on submitting ALTER SYSTEM command.

    I have a report of a list of active xml threads from our EM repository, which is pulled from 4 RAC instances. I have a region with this statement:
    select a.inst_id, a.sid,a.serial#,b.instance_name, b.host_name, a.machine, a.status
    from gv$session@emrepo a, gv$instance@emrepo b
    where a.action like 'XML%'
    and a.inst_id = b.instance_number
    order by a.inst_id
    The result shows me what I want. Now I want to be able to select the XML threads that I want to kill with the alter system kill command such as:
    alter system kill session 'sid, serial#'; (where sid and serial# is pulled from above).
    Question is how can I do this, plus need to figure out to make sure I am running this against the right RAC instance. Any help is appreciated. Thanks.
    Victor

    You can link to a confirmation page and set 2 items on that page SID and SERIAL# through the URL. Then create a process on the 2nd page that fires "On Submit" with the following code:execute immediate 'alter system disconnect session '||''''||:P2_SID||','||:P2_SERIAL||''' immediate';Create a button on the 2nd page to submit the page (fire your process when request = the button request).
    As far as how this works with RAC, you're on your own on that one ;)
    Thanks,
    Tyler

  • Killing sessions

    hi,
    i am using oracle 11gr1 in windows server service pack2.i have generated scripts to kill the user using alter system kill session 'sid,serial# and then dropping the same user.But at times i get the error that cannot drop user who is currently connected .when i check the state of the user in v$session it is in killed state.i want to avoid this and kill the user perfectly.
    can anyone tell me the solution or suggestion for this????
    thanks in advance
    Edited by: 793097 on Dec 17, 2010 3:12 AM

    A remote session open a server session, this is the one you must kill.
    I'm not sure, but when you kill a session the relation between v$process and v$session disapear. Then all you can do is wait.
    Perhaps I am wrong. Try this,
    select 'kill -9 ' || b.spid from v$process where b.addr = <v$session killed paddr>;
    And run the kill in OS, if OS is linux or unix...
    I am very sorry that we never help to you...
    793097 Newbie
    Handle:      793097
    Status Level:      Newbie (15)
    Registered:      Sep 6, 2010
    Total Posts:      94
    Total Questions:      57 (49 unresolved)
    Read this http://forums.oracle.com/forums/ann.jspa?annID=718

  • Oracle Killing Sessions

    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 TEST INACTIVE
    141 54482 TEST 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.
    Thanks,
    Moorthy.GS

    Hi,
    I locked that user also i killed again some inactive session and tried to drop that user. It works.
    Thanks...
    May know what is the reason, it generates new sessions.
    Cheers,
    Moorthy.GS

Maybe you are looking for

  • In month view, the entries hide each other. They stack up.

    I'm running a 2.3 GHz Intel Core i5 with 2GB 1333 MHz DDR3 memory system with iCal version 7.0. In month view, the entries sometimes stack on top of each other garbling the image, rather than listing down the day. I am beginning to miss appointments

  • Error while calling BAPI_GOODSMVT_CREATE back to back

    hi, all i am calling two back to back bapi, BAPI_GOODSMVT_CREATE  1st for movement type 313 and then for 315 for same serial nos (100 in nos.) I have even used bapi_transaction_commit with parameter wait = 'X', after  the 1st bapi(313).  The first BA

  • ITSMobile GUI doesn't fit on PDA

    Hi folks, I'm observing a strange behavior. I use a PDA with a barcode scanner and display the standard SAP ITSMobile menu (lm00) in the Internet Explorer of that Windows CE device. I've set the presentation format to 16x20. The PDA has a QVGA displa

  • Pls playlist of mp3 live stream doesn't work properly, what to do?

    Can others confirm the following issue with a live mp3 stream on version 7.0.2.16 on windows xp (sp2): Go to wnyc.org and click on the AM or FM live stream (32k) links at the top left of the page. They should link to either of the following urls: htt

  • Java.lang.Error: Default decoding not supported: Cp1251

    Hi! I just installe JRE 1.4 beta and i am getting the error specified in the subject. It is JRE 1.4 ENGLISH version installed on WIN98 russian. I don't need Int'l version of JRE. What does this error mean anyway? Regards, Artem