How to check locked session?

Hi all,
How do I check locked session,or which tables has been locked.and how to kill the lock session. i would need to do it in sqlplus. we'r not allowed to use toad.

SELECT sess.osuser AS OsUser, NVL (sess.program, sess.module) AS
Program, sess.terminal AS Terminal,
obj.Object_Name AS TABLE_NAME,
DBMS_ROWID.rowid_create (1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#,
ROW_WAIT_BLOCK#, ROW_WAIT_ROW#) AS ROW_ID
FROM dba_objects obj, v$session sess
WHERE sess.SID IN (SELECT a.SID
FROM v$lock a, v$session b
WHERE (id1, id2) IN (SELECT b.id1, b.id2
FROM v$lock b
WHERE b.id1 = a.id1 AND
b.id2 = a.id2 AND b.request > 0)
AND a.SID = b.SID
AND a.lmode = 0)
AND obj.object_id = sess.ROW_WAIT_OBJ#)

Similar Messages

  • How to check Locking sessions in oracle 10g

    Hi,
    I have tried to get locking sessions. i got the blocking session by using v$lock view.
    Pls help how to get locking sessions.
    Regards,
    Venkat

    Hi Venkat
    Or just run this independent of database version
    select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2;You can extend this query to find the username and machine (plus all other details) from v$session using the a.sid and b.sid from above
    To find the blocking session_
    SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID  = (SELECT blocker from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2
    *_To find the blocked session_*SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID = (SELECT blockee from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0 and a.id1=b.id1 and a.id2=b.id2
    Edited : Added blocker and blockee code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to check users session

    hi,
    I need to check user session like how much cpu a particular user consuming, user's session time and what activity he is doing(i.e. how many sql statement worked on and currently working).

    The below query will give you details on :
    SID/Serial, Foreground, Shadow, OS User, Ora User, User Module, Status Flags, Tran Active, Login Time, Last Call, Lock/Latch, Latch Spin, Current SQL stmt, Previous SQL stmt, Session Waits, WAITED Locks.
    set serveroutput on size 50000
    set echo off feed off veri off
    accept 1 prompt 'Enter Unix process id: '
    DECLARE
      v_sid number;
      s sys.v_$session%ROWTYPE;
      p sys.v_$process%ROWTYPE;
    BEGIN
      begin
        select sid into v_sid
        from   sys.v_$process p, sys.v_$session s
        where  p.addr     = s.paddr
          and  (p.spid    = &&1
           or   s.process = '&&1');
      exception
        when no_data_found then
          dbms_output.put_line('Unable to find process id &&1!!!');
          return;
        when others then
          dbms_output.put_line(sqlerrm);
          return;
      end;
      select * into s from sys.v_$session where sid  = v_sid;
      select * into p from sys.v_$process where addr = s.paddr;
      dbms_output.put_line('=====================================================================');
      dbms_output.put_line('SID/Serial  : '|| s.sid||','||s.serial#);
      dbms_output.put_line('Foreground  : '|| 'PID: '||s.process||' - '||s.program);
      dbms_output.put_line('Shadow      : '|| 'PID: '||p.spid||' - '||p.program);
      dbms_output.put_line('Terminal    : '|| s.terminal || '/ ' || p.terminal);
      dbms_output.put_line('OS User     : '|| s.osuser||' on '||s.machine);
      dbms_output.put_line('Ora User    : '|| s.username);
      dbms_output.put_line('User Module : '|| s.module);
      dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type);
      dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE'));
      dbms_output.put_line('Login Time  : '|| to_char(s.logon_time, 'Dy HH24:MI:SS'));
      dbms_output.put_line('Last Call   : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '990.0') || ' min');
      dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE'));
      dbms_output.put_line('Latch Spin  : '|| nvl(p.latchspin, 'NONE'));
      dbms_output.put_line('Current SQL statement:');
      for c1 in ( select * from sys.v_$sqltext
                  where HASH_VALUE = s.sql_hash_value order by piece) loop
        dbms_output.put_line(chr(9)||c1.sql_text);
      end loop;
      dbms_output.put_line('Previous SQL statement:');
      for c1 in ( select * from sys.v_$sqltext
                  where HASH_VALUE = s.prev_hash_value order by piece) loop
        dbms_output.put_line(chr(9)||c1.sql_text);
      end loop;
      dbms_output.put_line('Session Waits:');
      for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
        dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
      end loop;
    --  dbms_output.put_line('Connect Info:');
    --  for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
    --    dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
    --  end loop;
      dbms_output.put_line('Locks:');
      for c1 in ( select /*+ ordered */
              decode(l.type,
              -- Long locks
                          'TM', 'DML/DATA ENQ',   'TX', 'TRANSAC ENQ',
                          'UL', 'PLS USR LOCK',
              -- Short locks
                          'BL', 'BUF HASH TBL',  'CF', 'CONTROL FILE',
                          'CI', 'CROSS INST F',  'DF', 'DATA FILE   ',
                          'CU', 'CURSOR BIND ',
                          'DL', 'DIRECT LOAD ',  'DM', 'MOUNT/STRTUP',
                          'DR', 'RECO LOCK   ',  'DX', 'DISTRIB TRAN',
                          'FS', 'FILE SET    ',  'IN', 'INSTANCE NUM',
                          'FI', 'SGA OPN FILE',
                          'IR', 'INSTCE RECVR',  'IS', 'GET STATE   ',
                          'IV', 'LIBCACHE INV',  'KK', 'LOG SW KICK ',
                          'LS', 'LOG SWITCH  ',
                          'MM', 'MOUNT DEF   ',  'MR', 'MEDIA RECVRY',
                          'PF', 'PWFILE ENQ  ',  'PR', 'PROCESS STRT',
                          'RT', 'REDO THREAD ',  'SC', 'SCN ENQ     ',
                          'RW', 'ROW WAIT    ',
                          'SM', 'SMON LOCK   ',  'SN', 'SEQNO INSTCE',
                          'SQ', 'SEQNO ENQ   ',  'ST', 'SPACE TRANSC',
                          'SV', 'SEQNO VALUE ',  'TA', 'GENERIC ENQ ',
                          'TD', 'DLL ENQ     ',  'TE', 'EXTEND SEG  ',
                          'TS', 'TEMP SEGMENT',  'TT', 'TEMP TABLE  ',
                          'UN', 'USER NAME   ',  'WL', 'WRITE REDO  ',
                          'TYPE='||l.type) type,
           decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
                           4, 'S',    5, 'RSX',  6, 'X',
                           to_char(l.lmode) ) lmode,
           decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',
                             4, 'S', 5, 'RSX', 6, 'X',
                             to_char(l.request) ) lrequest,
           decode(l.type, 'MR', o.name,
                          'TD', o.name,
                          'TM', o.name,
                          'RW', 'FILE#='||substr(l.id1,1,3)||
                                ' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,
                          'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,
                          'WL', 'REDO LOG FILE#='||l.id1,
                          'RT', 'THREAD='||l.id1,
                          'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),
                          'ID1='||l.id1||' ID2='||l.id2) objname
           from  sys.v_$lock l, sys.obj$ o
           where sid   = s.sid
             and l.id1 = o.obj#(+) ) loop
        dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname);
      end loop;
      dbms_output.put_line('=====================================================================');
    END;
    undef 1
    set feedback on;
    set veri on;

  • How to check lock status of field in current document?

    Hi,
    How to check the status of field in current document(master agreement), that is whether its locked or not.
    I locked "Publish to Supplier" checkbox after MA is saved first time. Now, I want to check the status whether this field is locked or not in the same document.
    IsLockOwner( ) is not returning the correct value. Its not giving the current document field lock status.
    Is there any way to get current document field status?
    Thanks,
    Saloni

    Hi,
    If I understand correctly, your requirement is to get the value of this field "Publish to Supplier on". It can be achieved by writing the below:
    isVendorVisible = doc.getExtensionField("VENDOR_VISIBLE").get();
    Meaning, if the box is checked, it will return a value = true and if not then false.
    Hope this helps,
    Regards,
    Vikram Shukla

  • HT204387 how to check lock unlock status

    hello all
    how can i check status of iphone lock or unlock by imei
    if any one know help me me please

    Call AppleCare and give them the serial number.

  • How to check user/session generating a lot of archivelogs?

    Hi,
    On a 10g database, How do i look for the user/session that is generating a lot of archivelogs?
    thanks in advance,

    For currently connected sessions, you could query V$SESSTAT (joining to V$STATNAME). Thus,
    select s.sid, s.value
    from v$sesstat s, v$statname n
    where s.statistic#=n.statistic#
    and n.name = 'redo size'
    order by 2
    /However, there are a few complications :
    1. Persistent Sessions will show up with very high statistics, simply because they haven't disconnected. Many applications maintain Persistent Sessions for either of
    a. Monitoring and Running User Submitted or ScheduleD Jobs (eg in Oracle EBusiness Suite or Peoplesoft)
    b. Connection Pooling
    2. Sessions that have already disconnected will not appear in your report.
    Therefore, you'd have to "sample" sessions frequently and find the incremental redo size. Then, another complication hits you :
    c. Oracle reuses Session IDs. Once a session disconnects, another connecting session may get the same SID. It wouldn't get the same SERIAL# immediately so you might want to use a combination of SID+SERIAL# from V$SESSION as your key (you'd have to add V$SESSION into your monitoring query) Even then, I wouldn't guarantee that the pair wouldn't repeat after some time, particularly with instance restarts.
    You'd be better of using AUDSID from V$SESSION as that value is incremented (and not reused) by session auditing.

  • How to check MWA session details in Oracle Apps R12

    I am an Oracle Apps DBA. Current Issue is that sometimes users working with the RF Guns(Scanners) through telnet in MWA servers got hanged.
    They ask to kill their sessions.
    I do not know how to find the MWA loged in users sessions details. What I am able to find is , frm or web session details.
    Could you please guide how to gather these MWA connection details, with database and server process and session details.
    Thanks in advance for ur support.
    Regards,
    KMISRA

    Koushikinath wrote:
    I am an Oracle Apps DBA. Current Issue is that sometimes users working with the RF Guns(Scanners) through telnet in MWA servers got hanged.
    They ask to kill their sessions.
    I do not know how to find the MWA loged in users sessions details. What I am able to find is , frm or web session details.
    Could you please guide how to gather these MWA connection details, with database and server process and session details.
    Thanks in advance for ur support.
    Regards,
    KMISRAPlease see these docs.
    MWA Server Hangs on R12 Environments [ID 559614.1]
    Which parameters control the maximum number of user connections per MWA listener [ID 567214.1]
    Mobile Web Applications (MWA) Troubleshooting Tips for Release 12 Mobile Web Applications Server [ID 782162.1]
    Mobile Application Server - Advanced Configurations and Topologies for Mobile Web Applications (MWA)of E-Business Suite 11i and R12 [ID 1081404.1]
    Mobile Web Applications Server - MWA Troubleshooting Tips for E-Business Suite 11i and R12 Oracle Mobile Application Server [ID 269991.1]
    How to Enable WMS / MSCA Logging? [ID 338291.1]
    Thanks,
    Hussein

  • How to check blocking locks

    I have a query as to how to check for blocking locks in the database. I am trying to check it from TOAD but the session of TOAD is hanging. I hope, my question is clear.
    Please, help in solving the doubt.
    regards

    Hi user574290,
    Here is other script:
    clear screen
    set serveroutput on
    BEGIN
    dbms_output.enable(1000000);
    for do_loop in (select session_id, a.object_id, xidsqn, oracle_username, b.owner owner,
                    b.object_name object_name, b.object_type object_type
                    FROM v$locked_object a, dba_objects b
                       WHERE xidsqn != 0
                        and b.object_id = a.object_id)
    loop
        dbms_output.put_line('.');
        dbms_output.put_line('Blocking Session   : '||do_loop.session_id);
         dbms_output.put_line('Object (Owner/Name): '||do_loop.owner||'.'||do_loop.object_name);
        dbms_output.put_line('Object Type        : '||do_loop.object_type);
         for next_loop in (select sid from v$lock
                         where id2 = do_loop.xidsqn
                             and sid != do_loop.session_id)
         LOOP
              dbms_output.put_line('Sessions being blocked   :  '||next_loop.sid);
        end loop;          
    end loop;
    END;
    /Best Regards,
    Francisco Munoz Alvarez
    www.oraclenz.com

  • How to check the date of an Oracle session

    hello
    How to check how long a session was opened?
    thx

    set lines 100 pages 999
    col ID          format a15
    col osuser     format a15
    col login_time     format a14
    select      username
    ,     osuser
    ,     sid || ',' || serial# "ID"
    ,     status
    ,     to_char(logon_time, 'hh24:mi dd/mm/yy') login_time
    ,     last_call_et
    from     v$session
    where     username is not null
    order     by login_time
    Regards,
    Andy Barry

  • How to check if "create session" is being audited in the aud$

    Specifically, how do the determine if "create session" is being audited? Assume audit_trail=db_extended, audit_sys_operations=true and audit_file_dest has been set. Please specifically how to check if "create session" is being audited. Thanks

    SQL> connect test/test
    Connected.
    SQL> connect / as sysdba
    Connected.
    SQL> select username, action_name, to_char(timestamp,'DD/MON HH24:MI') from dba_audit_trail where action_name like 'LOG%';
    USERNAME                       ACTION_NAME                  TO_CHAR(TIMESTAMP,'DD/MONHH24
    TEST                           LOGON                        10/JANV. 19:32
    TEST                           LOGOFF                       10/JANV. 19:32
    SQL> select to_char(sysdate,'DD/MON HH24:MI') from dual;
    TO_CHAR(SYSDATE,'DD/MONHH24:M
    10/JANV. 19:33

  • [Help] How to check the object locks held by a specific thread?

    As the title I want to check locks held by a specific thread. How can I do this? In Java lock is acquired and release automatically by stating synchronized keyword. I have no idea on how to check the lock status and who owns whick lock.
    Regards,
    Skeeter

    Look for the method:
        public static native boolean holdsLock(java.lang.Object);Its in the java.lang.Thread class. It will check the lock status for an object for the calling thread.

  • How to check if remote phone locking in E5 is work...

    how to check if remote phone locking in E5 is working

    If the phone is off nothing can be done about it.
    As is evident in the thread that aspergerguy linked you can check by sending the required sms to your phone but that guy was reporting what sounds like a bug if you do just send the message to test.
    Honestly you have very little time to actually do something about a stolen phone. It's not like tracking a car which itself is not 100% effective. I don't bother with such software it's actually for the stupid thieves.
    Show your appreciation. Hit that kudos button real hard

  • How to check for locks on a table inside a program?

    Hi Gurus,
    Kindly let me know how to check for a lock on a particular table inside a program.I know that we can see locks on table held by a user from transaction SM12 but my requirement is to check for lock on MARA/MARC/MARV if lock exist then bypass my code else do the code.
    Kindly suggest or give code to check for a lock on a particular table.
    Thanks in advance
    Sudipto

    FAQ.  Locked.

  • Hi, i want to know how to check my iphone is original unlocked or locked?

    Hi, i want to know how to check my iphone is original unlocked or locked?

    A G5 iMac don't have video-in capability, so you can't just use a simple cable to connect the two Macs.
    Have a look/try at ScreenRecycler http://www.screenrecycler.com/ScreenRecycler.html
    Stefan

  • How to check iPad/iPhone is it unlocked or locked?

    HI~~
    I've bought an iPad 3, Verizon model. I wonder how to check my iPad is it unlocked or locked version.
    Thanks.

    You should be able to call AppleCare and give them the serial number. They should be able to tell you if it's locked and who it's locked to.

Maybe you are looking for

  • Unmount SD Card Part 2

    FCP X 10.2 I have an 8 gig SD card I have mounted that has audio files on it. I imported the audio in FCP X with no problem. Now I want to unmount it so I can mount the SD card with the VIDEO files. I select Import to get the import dialog, I click o

  • Ipod is not able to snyc with laptop. ipod is locked to snyc with itunes, not able to.

    ipod is not able to snyc with laptop. ipod is locked to snyc with itunes. the ipod is not snycing with laptop.

  • Custom Icon Issue

    I have changed icons before, when the new itunes came out a while back and I went and made my own Totoro-themed icon to replace the black on blue one. Anyways, I'm trying to change icons for some other files and it doesn't seem to work. When I paste

  • Idoc extraction from erp

    Hi colleagues, i'm trying to create xi scenario which transfers idoc from erp system to the xml file for the mdm system. I've already created all the neccessary things in integration repository and integration directory. And now i got stuck with ALE

  • Nokia 2730classic app can't connect to internet

    Hi, I'm trying to use the E-mail application of my phone (Nokia 2730 classic) but when I try to connect it says "Comunication Error", I've tried with the Opera mini browser and the native web browser and definitely there is a internet connection avai