您的位置:首页 > 数据库 > Oracle

oracle查询会话锁并解锁

2008-07-04 17:17 309 查看
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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: