天天看點

oracle查詢會話鎖并解鎖

session 1: C:/>sqlplus scott/tiger SQL> select * from t;          A B                    C ---------- -------------------- --------------------        111 aa                   bb        222 hello                world SQL> update t set b='hi' where a=222; 已更新 1 行。 session 2: C:/>sqlplus hxg/hxg SQL> select * from scott.t;          A B                    C ---------- -------------------- --------------------        111 aa                   bb        222 hello                world SQL> update scott.t  set b='good' where a=222; 挂起等待。。。。 another  session 2(session 22): C:/>sqlplus hxg/hxg SQL> select s.sid,s.SERIAL#,s.machine,o.object_name,l.oracle_username,l.locked_mode   2  from  v$locked_object  l,v$session  s,all_objects  o   3  where  l.session_id=s.sid  and  l.object_id=o.object_id ;        SID    SERIAL# ---------- ---------- MACHINE ---------------------------------------------------------------- OBJECT_NAME                    ORACLE_USERNAME                LOCKED_MODE ------------------------------ ------------------------------ -----------        148          2 MSHOME/TECH037 T                              HXG                                      3        150          2 MSHOME/TECH037 T                              SCOTT                                    3 SQL> alter system kill session '150,2'; 系統已更改。 此時:session 2: SQL> update scott.t  set b='good' where a=222; 已更新 1 行。 SQL>