查看锁表进程SQL语句

1 SELECT S.SID SESSION_ID, S.USERNAME, DECODE(LMODE, 0 , ' None ' , 1 , ' Null ' , 2 , ' Row-S (SS) ' , 3 , ' Row-X (SX) ' , 4 , ' Share ' , 5 , ' S/Row-X (SSX) ' , 6 , ' Exclusive ' , TO_CHAR(LMODE)) MODE_HELD, DECODE(REQUEST, 0 , ' None ' , 1 , ' Null ' , 2 , ' Row-S (SS) ' , 3 , ' Row-X (SX) ' , 4 , ' Share ' , 5 , ' S/Row-X (SSX) ' , 6 , ' Exclusive ' , TO_CHAR(REQUEST)) MODE_REQUESTED, O.OWNER || ' . ' || O. OBJECT_NAME || ' ( ' || O.OBJECT_TYPE || ' ) ' , S.TYPE LOCK_TYPE, L.ID1 LOCK_ID1, L.ID2 LOCK_ID2 FROM V$LOCK L, SYS.DBA_OBJECTS O, V$SESSION S WHERE L.SID = S.SID AND L.ID1 = O. OBJECT_ID 执行上记SQL语句,可以查寻到数据库中的锁的情报. SESSION_ID, USERNAME, MODE_HELD, MODE_REQUESTED, OBJECT_NAME, LOCK_TYPE, LOCK_ID 分别是 拥有锁的SESSION_ID,拥有锁的USERNAME,锁的执行模式MODE_HELD,锁的请求MODE_REQUESTED,锁所在的数据库对象名 ,锁的类型,锁的ID 2、 查看锁表进程SQL语句1: select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_mode from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id and lo.session_id = sess.sid; 查看锁表进程SQL语句2: select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 杀掉锁表进程: 如有記錄則表示有lock,記錄下SID和serial# ,將記錄的ID替換下面的738,1429,即可解除LOCK alter system kill session '738,1429';

你可能感兴趣的:(oracle,sql,OS)