ALTER SYSTEM KILL SESSION privilege

Hi All,
Is there any possibility to use this command from a without having DBA priviileges, what is the privilege to be grantd to the ordinary users to execute ALTER SYSTEM KILL SESSION... statement..
Thanks in advance

The procedure proposed by Rusell would be more or less so:
SQL> create or replace procedure kill_session
  2  ( v_sid number, v_serial number )
  3  as
  4  v_varchar2 varchar2(100);
  5  begin
  6  execute immediate 'ALTER SYSTEM KILL SESSION '''
  7  || v_sid || ',' || v_serial || '''';
  8  end;
  9  /
Procedure created.
SQL> select username, sid, serial# from v$session;
USERNAME                              SID    SERIAL#
                                      147       5078
SYS                                   148       6161
                                      151       6769
                                      156          1
                                      158          1
                                      159          1
REPOS_OWNER                           161      14502
                                      163          1
                                      164          1
                                      165          1
                                      166          1
USERNAME                              SID    SERIAL#
                                      167          1
                                      168          1
                                      169          1
                                      170          1
15 rows selected.
SQL>
SQL> exec kill_session(161,14502);
PL/SQL procedure successfully completed.
SQL>Joel Pérez
http://otn.oracle.com/experts

Similar Messages

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

  • Abend while executing alter system kill session command

    I have a ML350 G3 Hp server(Xeon 2.4 Ghz) running oracle 8.1.5 on Novell 5.1. Frequently i have locking problems in my software. So when i tried to kill the active session using alter system kill session 'sid, serial#' my server produce following error:
    Fatal Exception (Number 14, cause abend: Page fault running process: orcl_000000fe code executing in module core81.nlm v8.1d at offset +6c490h). Any suggestions.

    This forum is for posting feedback about the OTN site.
    The best place for your question is probably a Database forum.
    There is a list of Database forums here:
    http://forums.oracle.com/forums/index.jsp?cat=18

  • Regarding Alter System Kill Session

    Hi Guys,
    I have to do db refresh from the build .For this I have to kill the sessions and drop the users and recreate the users with the latest build.As the application is running and there are some idle sessions, I have to kill the sessions and drop the users for that I am using a code as below
    DECLARE
    v_alt_stmt VARCHAR2(1000) := 'ALTER SYSTEM KILL SESSION ''';
    v_kill_stmt VARCHAR2(1000);
    CURSOR cur_session IS
    SELECT s.type type,
    s.sid sid,
    s.serial# srl_no,
    s.username user_name,
    s.PROGRAM prog_name
    FROM v$session s JOIN gv$process p ON p.addr = s.paddr and s.type='USER';
    BEGIN
    EXECUTE IMMEDIATE 'ALTER SYSTEM ENABLE RESTRICTED SESSION';
    DBMS_OUTPUT.PUT_LINE('The Session has been put in the restricted mode');
    FOR v_cur_ssn IN cur_session
    LOOP
    BEGIN
    v_kill_stmt := v_alt_stmt || v_cur_ssn.sid || ',' || v_cur_ssn.srl_no || '''';
    DBMS_OUTPUT.PUT_LINE(v_kill_stmt);
    EXECUTE IMMEDIATE v_kill_stmt;
    EXCEPTION
    WHEN others THEN
    -- DBMS_OUTPUT.PUT_LINE('The current sessions sid is ' || v_cur_ssn.sid || ' and the srl no is ' || v_cur_ssn.srl_no || ' can not be killed');
    END;
    END LOOP;
    EXECUTE IMMEDIATE 'ALTER SYSTEM DISABLE RESTRICTED SESSION';
    DBMS_OUTPUT.PUT_LINE('The restricted mode of the system has been removed');
    END;
    But sometimes after killing the sessions there are some os processes are going on,to avoid that I have to use 'ALTER SYSTEM DISCONNECT SESSION ''' and 'MMEDIATE' it is workig fine .
    Can Any one tell me the logical difference between kill sessions and disconnect
    Any information will be highly appreciated.
    Thanks in advance
    Prafulla

    >
    Can Any one tell me the logical difference between kill sessions and disconnect
    >
    Disconnect can be used to disconnect immediately without waiting for any ongoing transactions to complete and recovers all session resousrces.
    Kill rolls back ongoing transactions and partially recovers session resources.
    Kill is simiilar to SHUTDOWN IMMEDIATE while disconnect is more like SHUTDOWN ABORT.
    See DISCONNECT SESSION Clause in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm
    >
    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.
    >
    And KILL SESSION in the same doc next section
    >
    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.

  • Alter system kill session always gives ORA-00030

    Hello
    Im writing a tool for oracle and one of its features requires killing user session (Im connecting with JDBC). The database Im testing on is 11.2.0.2.
    I find the sid and the serial# without problems, than I issue the "alter system kill session 'x,y' immediate" command.
    So far so good, but I always get an ORA-00030 error saying this session cannot be found.
    I double check and the session does exist in the database.
    Because I want the tool to make the kill, killing via the OS is not an option.
    Its doesn't look like a permission problem because it gives the same error even when connected as system.
    Whats wrong ? does this kill command work at all ? Whats its limitations ?
    Thanks
    Guy Shilo
    Edited by: user13266377 on Jun 9, 2011 1:15 AM

    user13266377 wrote:
    Hello
    Im writing a tool for oracle and one of its features requires killing user session (Im connecting with JDBC). The database Im testing on is 11.2.0.2.
    I find the sid and the serial# without problems, than I issue the "alter system kill session 'x,y' immediate" command.
    So far so good, but I always get an ORA-00030 error saying this session cannot be found.
    I double check and the session does exist in the database.
    Because I want the tool to make the kill, killing via the OS is not an option.
    Its doesn't look like a permission problem because it gives the same error even when connected as system.
    Whats wrong ? does this kill command work at all ? Whats its limitations ?
    Thanks
    Guy Shilo
    Edited by: user13266377 on Jun 9, 2011 1:15 AMyou cannot kill the session already killed or disconnected from the session.
    refer the link:- this may help you to write scripts to kill session using dbms_scheduler
    Grant restricted and kill sessions.

  • Alter System Kill Session Not Working

    I'm not certain as to what the problem may be, but the following code does not work in that the session is not being disconnected.
    The attempt is to have this trigger kill a user's logon session if the user is attempting to run a program named 'ex_oc.exe'
    I've tested the code (getting the values back to the table as expected) and it appears to be working but it doesn't execute.
    I've also tried ''ALTER SYSTEM DISCONNECT SESSION'.
    Database is 11g.
    Any ideas?
    Thanks
    CREATE OR REPLACE TRIGGER SYS.DENY_MSB_TRIGGER_UPDATEDD
    AFTER LOGON ON Database
    DECLARE
    v_programname varchar2(64);
    v_logontime date;
    v_process varchar2(24);
    v_machine varchar2(64);
    v_sid number;
    v_serialnum number;
    v_username varchar2(30);
    v_stmt2run VARCHAR2(327);
    cur INTEGER;
    ret INTEGER;
    v_string VARCHAR2(500);
    BEGIN
    SELECT PROGRAM, PROCESS, MACHINE, SID, SERIAL#, USERNAME
    INTO v_programname, v_process, v_machine, v_sid, v_serialnum, v_username
    FROM V$SESSION
    WHERE PROGRAM = LOWER('ex_oc.exe');
    INSERT INTO SAUDIT.DENYMSB (PROGRAM, PROCESS, MACHINE, SID, SERIALNUM, USERNAME)
    VALUES (v_programname, v_process, v_machine, v_sid, v_serialnum, v_username );
    v_string := 'ALTER SYSTEM KILL SESSION' || CHR(39)||v_sid||','||v_serialnum|| CHR(39)||' IMMEDIATE';
    EXECUTE IMMEDIATE v_string;
    END;
    Edited by: user12451703 on Jan 14, 2010 8:57 AM
    Edited by: user12451703 on Jan 14, 2010 8:58 AM

    user12451703 wrote:
    I'm not trying to kill my own session.
    Trigger written by Sys and running it as a generic user.You completely misunderstand triggers. Same as SP/SF trigger is always executed in invoking session on behalf of trigger owner. Below is a slighly modified version of your trigger that does not allow user U1 to connect by killing user U1 session:
    SQL> connect scott as sysdba
    Enter password: *****
    Connected.
    SQL> CREATE OR REPLACE TRIGGER SYS.DENY_MSB_TRIGGER_UPDATEDD
    2 AFTER LOGON ON Database
    3 DECLARE
    4 v_programname varchar2(64);
    5 v_logontime date;
    6 v_process varchar2(24);
    7 v_machine varchar2(64);
    8 v_sid number;
    9 v_serialnum number;
    10 v_username varchar2(30);
    11 v_stmt2run VARCHAR2(327);
    12 cur INTEGER;
    13 ret INTEGER;
    14 v_string VARCHAR2(500);
    15 BEGIN
    16 SELECT PROGRAM, PROCESS, MACHINE, SID, SERIAL#, USERNAME
    17 INTO v_programname, v_process, v_machine, v_sid, v_serialnum, v_username
    18 FROM V$SESSION where username = 'U1';
    19 EXECUTE IMMEDIATE ('ALTER SYSTEM KILL SESSION ''' || v_sid || ',' || v_serialnum || '''');
    20 EXCEPTION
    21 WHEN OTHERS THEN
    22 RAISE_APPLICATION_ERROR(-20001, 'Execution of this program not allowed', TRUE);
    23 END;
    24 /
    Trigger created.
    SQL> create user u1 identified by u1
    2 /
    User created.
    SQL> grant create session to u1
    2 /
    Grant succeeded.
    SQL> connect u1/u1
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: Execution of this program not allowed
    ORA-06512: at line 20
    <font color=red size =2>ORA-00027: cannot kill current session</font>
    Warning: You are no longer connected to ORACLE.
    SQL>
    Also, user not that keen to change the name of the exe.Is cex_soc.exe client side executable? If so what prevents user from renaming it?
    SY.

  • Alter system kill session in RAC

    Hi,
    After identifying all inactive jdbc sessions or blocking sessions from gv$session or gv$lock respectively, should alter system kill session executed in both instances of RAC?, Can't we execute like alter system kill session ' inst_id,sid,serial#' from a single instance to kill all the session of RAC instances?
    So, above problem answered in 11g as:
    Alter system kill session ‘SID, serial#, @instance_id’;
    Eg: ALTER SYSTEM KILL SESSION ‘115,9779,@1';
    So, In our environment, most of the databases are in 10gR1 or 10g R2. Is there any patch for 10g Where instance_id can be recognized by alter system kill session?
    Thanks,
    Sunil.

    Hi Dan,
    Not sure what you mean by "instance specific kill session capability".
    To be clear, I'm speaking of a new feature, introduced in 11gR1, that provides for an optional third parameter to 'alter system kill session', which allows you to kill a session on a remote instance, in a RAC environment.
    Documentation is here:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_2013.htm#i2065117
    -Mark

  • 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

  • ALTER SYSTEM KILL SESSION

    Hello Everybody,
    1) Is there any difference between “ALTER SYSTEM KILL SESSION & “kill -9”? Which one is the preferred method?
    2) When we do alter system kill 'sid, serial#'. Are we killing the user process or the server process?
    thanks in advance

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION)
    >
    Hello Everybody,
    1) Is there any difference between “ALTER SYSTEM KILL SESSION & “kill -9”? Which one is the preferred method?
    2) When we do alter system kill 'sid, serial#'. Are we killing the user process or the server process?
    >
    You should only use the 'kill' from the OS as a last resort.
    There are TWO Oracle options: KILL session and DISCONNECT session. Only rarely, in my experience will DISCONNECT SESSION not get the job done.
    See ALTER SYSTEM in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm
    >
    end_session_clauses
    The end_session_clauses give you several ways to end the current session.
    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.
    See Also:
    "Disconnecting a Session: Example"
    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. Your session and the session to be terminated must be on the same instance unless you specify integer3.You must identify the session with 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.
    •For the optional integer3, specify the ID of the instance where the target session to be killed exists. You can find the instance ID by querying the GV$ tables.
    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.
    See Also:
    "Terminating a Session: Example"
    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.

  • ALTER SYSTEM KILL SESSION 에 대하여(ORA-30)

    제품 : ORACLE SERVER
    작성날짜 : 1997-07-30
    ALTER SYSTEM KILL SESSION 에 대하여
    --- Problem
    사용자는 다음과 같은 상황에서 session 을 kill 하려는 시도를 하게 된다.
    1. os 에는 process 가 존재하지 않지만, v$session 에는 active 로 존재하고
    있을 경우
    2. shadow process 는 살아 있는데, client machine 을 rebooting 한 경우
    3. session 이 걸고 있던 lock 을 release 해야 할 경우
    4. OS 나 Oracle 의 자원을 지나치게 많이 사용하여 성능을 저하시키는
    process
    그런데, alter system kill session ('sid, serial#'); 후에 다음과 같은
    에러가 발생할 경우가 있다.
    ora-00030, 00000, "user session ID does not exist"
    // *Cause:  The user session id no longer exists, probably because the
    // session was logged out.
    // *Action: Use a valid session ID.
    --- 원인과 대책
    kill session을 할 수 없는 이유는 PMON이 이미 이 session을 delete하고 있는
    중이기 때문이다. 즉, PMON 이 dead session 을 clean-up 하고 있는 중에는
    serial number의 값이 증가한다.
    문제는 PMON이 process를 kill하는 시간인데, transaction의 크기에 따라,
    PMON의 rollback 시간이 결정된다. 먼저 PMON은 dead process를 찾아내어,
    이 process가 사용한 resource 를 release하는 시도를 한다.
    PMON은 계속 이 작업을 시도하다가 마침내, free buffer의 부족으로 더 이상
    resource를 free-up 하지 못하게 된다.
    이 때, 이 process를 delete하고 있다는 message를 trace file에 출력하는데,
    이것은 process를 delete하는 데 필요한 resource(data cache 내의 free buffer)
    의 부족으로 위의 작업이 지연되고 있다는 의미이다.
    PMON이 process 를 clean-up 할 때 걸리는 시간은, 5분에서 24 시간까지 소요
    될 수 있다. 문제는 이 process가 hold 하고 있는 lock으로 인해 특정 작업이
    수행되지 못하는 데 있다. MTS 를 사용할 때는 configuration MTS setting,
    sqlnet.expire_time 사용)에 따라 다르지만, clean-up 작업을 하는데 72 시간이
    소요된 경우도 있다.
    아직까지는 PMON이 작업을 마칠 때까지 기다리는 방법 또는 db를 restartup하는
    방법 밖에는 없다.
    --- PMON 의 작업
    PMON은 network failure 나 기타의 원인으로 생긴 old process connection을
    clean-up 하는 역할을 한다. 그런데, PMON 은 clean-up 해야 하는 connection
    중에 정해진 개수 만큼의 transaction 을 rollback 할 수 있는데, 이 값은
    initSID.ora 의 cleanup_rollback_entries(default = 20) 에 의해 결정된다.
    예를 들어, 1000 개의 uncommitted update가 있다면, 일정한 시간마다
    cleanup_rollback_entries 의 개수 만큼의 record 만 rollback 할 수 있으므로
    이 작업 동안에 lock 은 그대로 유지된다.
    PMON 은 위의 작업 이외에 DB maintenance 역할이 있으므로, 위의 rollback 이
    비교적 빠르게 처리되지 못할 수도 있다. 이러한 rollback을 빠르게 처리하기
    위하여 cleanup_rollback_entries 를 늘릴 수도 있다. 그러나, 그 만큼 일정
    시간 동안 PMON 의 작업이 많아지게 되므로, 다른 사용자들의 작업 요청이
    느려지게 되는 trade-off 가 있으므로, 신중히 고려한 후에 수정하는 것이
    바람직하다.
    alter system kill session 에 의해서도 위와 같이 rollback 이 이루어지는데,
    이 session 이 완전히 clean-up 되기 전까지 v$session, v$process에 남아 있게
    된다.
    --- ALTER SYSTEM KILL SESSION 을 하기 전에 ...
    kill session 을 원할 경우는 다음의 순서대로 작업하는 것이 좋다.
    1. kill the user process first
    2. wait for 3 - 4 minutes
    3. query v$session
    4. if any information find in v$session, query v$lock
    like
    select count(*) from v$lock where SID ='sid';
    위의 count(*) 가 0 이 아니라면, 아직 PMON 이 rollback을 끝내지 못한 경우
    이므로 다시 얼마 후에 v$lock 을 조회하여 lock 의 개수가 감소하였는지
    반복적으로 확인한다.
    만약, 이 값이 전혀 변하지 않았다면, ALTER SYSTEM KILL SESSION 을 수행하고
    v$session, v$lock을 query 하여 변화가 있는지 확인하여 변화가 있다면,
    좀 더 기다린다.
    그래도, v$lock 의 count(*) 가 0 이 되지 않을 경우, 마지막으로 수행할 수
    있는 유일한 방법은 instance 를 restartup 하는 것이다.

    user13266377 wrote:
    Hello
    Im writing a tool for oracle and one of its features requires killing user session (Im connecting with JDBC). The database Im testing on is 11.2.0.2.
    I find the sid and the serial# without problems, than I issue the "alter system kill session 'x,y' immediate" command.
    So far so good, but I always get an ORA-00030 error saying this session cannot be found.
    I double check and the session does exist in the database.
    Because I want the tool to make the kill, killing via the OS is not an option.
    Its doesn't look like a permission problem because it gives the same error even when connected as system.
    Whats wrong ? does this kill command work at all ? Whats its limitations ?
    Thanks
    Guy Shilo
    Edited by: user13266377 on Jun 9, 2011 1:15 AMyou cannot kill the session already killed or disconnected from the session.
    refer the link:- this may help you to write scripts to kill session using dbms_scheduler
    Grant restricted and kill sessions.

  • 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

  • Can I execute "Alter System Disconnect Session" in a OLE VB Script?

    Will this work? If not - How to do it?
    The speadsheet contains a list of sid's and serial#. I want to highlight a cell containing a username, then run the kill session macro on it.
    Sub Kill_Session()
    Dim KillStatement As Object
    DBPassword = "uuuu/pppppppp"
    DatabaseName = "dddd"
    Set objSession = CreateObject("OracleInProcServer.XOraSession")
    Set objdatabase = objSession.opendatabase(DatabaseName, DBPassword, 0&)
    objdatabase.Parameters.Add "SERIAL", 0, 2
    objdatabase.Parameters("SERIAL").ServerType = 1
    objdatabase.Parameters.Add "SID", 0, 2
    objdatabase.Parameters("SID").ServerType = 1
    Inputdata = ActiveCell.Value
    RowNo = ActiveCell.Row
    objdatabase.Parameters("SERIAL").Value = Worksheets("Sheet1").Cells(RowNo, 13)
    objdatabase.Parameters("SID").Value = Worksheets("Sheet1").Cells(RowNo, 12)
    Set OraSqlStmt = objdatabase.CreateSQL("ALTER SYSTEM DISCONNECT SESSION ':SID, :SERIAL' IMMEDIATE;", 0&)
    MsgBox objdatabase.Parameters("SID").Value
    MsgBox objdatabase.Parameters("SERIAL").Value
    objdatabase.Parameters.Remove ("SERIAL")
    objdatabase.Parameters.Remove ("SID")
    End Sub

    on 10gR1/10gR2, you can not use
    ALTER SYSTEM KILL SESSION ‘115,9779,@1';that start from 11gR1
    Only
    * For integer1, specify the value of the SID column.
    * For integer2, specify the value of the SERIAL# column.
    ALTER SYSTEM KILL SESSION ‘115,9779';http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_2013.htm#SQLRF00902
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_2013.htm#SQLRF00902
    You may use crontab to help ....
    Example about blocking (SID):
    select 'ALTER SYSTEM KILL SESSION ''' ||sid||','||serial#|| ''' IMMEDIATE;' from gv$session s where sid in (
    select distinct(l1.sid) from
    gv$lock l1, gv$lock l2
    where l1.block = 1 and l2.request > 0
    and l1.id1=l2.id1
    and l1.id2=l2.id2
    ) AND INST_ID = (select INSTANCE_NUMBER from v$instance )and ....
    Good Luck

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

  • 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

Maybe you are looking for

  • CTS+ configuration in PI 7.4 to transport SLD specific data

    Hello Guys, I am doing CTS+ configuration for PI System SLD Vesrion 7.4 to transport J2ee as well as SLD specific data through transports. My CTS server is Solman System. I have created a CTS user in Solman System and in PI NWA I have defined destina

  • CRM Survey Question

    Hi, All: Currently, we plan to use surveys provided by CRM_Survey_Suite tool. According to the requirement, the surveys will be transport to sales PDAs. Is there any APIs or BAPIs can be used to get the survey data, such as layout, questions, answers

  • Upgrading Graphics Card (Urgent)

    Ok so recently at Christmas I believe I bought a lenovo H530 desktop, and I was wondering if I could upgrade the graphics card to a Nvdidia GTX 750TI. I want to know if its compatibale with the computer and if not, what is the best graphics card to g

  • Reading and wrting with selectors

    Heres the code is used for Reading. The problem is that when the client send the server some bytes it goes into the loop and exits which is good however it does not delete the Selected Keys set from the selector. I thought that after ever slection pr

  • Receiving error code 0x80092013

    Receiving an error code 0x80092013 on home PC with Windows 7 when trying too access the iphone store. With the lap top no problems.