欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数据锁表及解锁  

程序员文章站 2022-03-25 21:13:45
...
--锁表查询SQLSELECT object_name, machine, s.sid, s.serial#
FROM gv$locked_object l, dba_objects o, gv$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid;


--释放SESSION SQL:
--alter system kill session 'sid, serial#';
ALTER system kill session '23, 1647';



--研究表级锁及行级锁
SELECT S.SID                             SID,
         S.USERNAME                        USERNAME,
         S.MACHINE                         MACHINE,
         L.TYPE                            TYPE,
         O.OBJECT_NAME                     OBJECT_NAME,
         DECODE(L.LMODE, 0, 'None',
                         1, 'Null',
                         2, 'Row Share',
                         3, 'Row Exlusive',
                         4, 'Share',
                         5, 'Sh/Row Exlusive',
                         6, 'Exclusive')   lmode,
    DECODE(L.REQUEST, 0, 'None',
                           1, 'Null',
                           2, 'Row Share',
                           3, 'Row Exlusive',
                           4, 'Share',
                           5, 'Sh/Row Exlusive',
                           6, 'Exclusive') request,
         L.BLOCK                           BLOCK
  FROM   V$LOCK L,
         V$SESSION S,
         DBA_OBJECTS O
  WHERE  L.SID = S.SID
         AND USERNAME != 'SYSTEM'
         AND O.OBJECT_ID(+) = L.ID1
         AND S.SID IN ( 199,195)
  ORDER  BY S.SID;