RAC锁查找语句

select SESS.INST_ID,sess.sid,
    sess.serial#,
    lo.oracle_username,
    lo.os_user_name,
    ao.object_name,
    lo.locked_mode
    from GV$locked_object lo,
    dba_objects ao,
    GV$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid and lo.ORACLE_USERNAME='INFORES' AND SESS.LAST_CALL_ET>600



--抓取锁的使用SQL语句
select a.username,
       a.machine,
       a.sid,
       a.serial#,
       a.last_call_et seconds,
       b.id1,
       c.sql_text     sql
  from gv$session a, v$lock b, v$sqltext c
 where a.username is not null
   and a.lockwait = b.kaddr
   and c.hash_value = a.sql_hash_value;

-----------------------------------
SELECT /*+ rule */ s.username,
decode(l.type,'TM','TABLE LOCK',
'TX','ROW LOCK',
NULL) LOCK_LEVEL,
o.owner,o.object_name,o.object_type,
s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser
FROM gv$session s,gv$lock l,dba_objects o
WHERE l.sid = s.sid
AND l.id1 = o.object_id(+)
AND s.username is NOT NULL and s.LAST_CALL_ET>1000 and l.TYPE='TX'


------------------SQL--------------
SELECT l.session_id sid, s.serial#, l.locked_mode, l.oracle_username, s.user#,
l.os_user_name,s.machine, s.terminal,a.sql_text, a.action
FROM gv$sqlarea a,gv$session s, gv$locked_object l
WHERE l.session_id = s.sid
AND s.prev_sql_addr = a.address  AND S.SID=3773
ORDER BY sid, s.serial#



-----------------------------------RAC锁抓取-----------------------------
select a.INST_ID,spid os_process ,a.sid blocker_sid,a.serial#,a.status,c.sid as waiter_sid,'alter system kill session '''||a.SID||','||a.SERIAL#||''';' kill_session,a.username as blocker,machine, a.module,
       P.program, d.sql_text ,
       b.type,decode(b.lmode,0,'None',1,'Null',2,'Row share',
       3,'Row Exclusive',4,'Share',5,'Share Row Exclusive',6,'Exclusive') lock_mode,
       b.ctime as time_held,
       decode(c.request,0,'None',1,'Null',2,'Row share',
              3,'Row Exclusive',4,'Share',5,'Share Row Exclusive',6,'Exclusive') request_mode,
       c.ctime time_waited
  from  gv$lock b, gv$enqueue_lock c, gv$session a,gv$process p, gv$sql d
 where a.sid = b.sid
   and p.inst_id=a.inst_id
   and a.sql_address = d.address(+)
   and p.addr=a.paddr
   and b.id1 = c.id1(+)
   and b.id2 = c.id2(+)
   and c.type(+) = 'TX'
   and b.type = 'TX'
   and b.block = 1
   order by time_held desc ,time_waited desc;
   
  -- alter system kill session '4476,40869';


-----------------------------------RAC锁抓取-----------------------------
select a.INST_ID,spid os_process ,a.sid blocker_sid,a.serial#,a.status,'alter system kill session '''||a.SID||','||a.SERIAL#||''';' kill_session,a.username as blocker,machine, a.module,
       P.program, d.sql_text ,
       b.type,decode(b.lmode,0,'None',1,'Null',2,'Row share',
       3,'Row Exclusive',4,'Share',5,'Share Row Exclusive',6,'Exclusive') lock_mode,
       b.ctime as time_held,c.sid as waiter_sid,
       decode(c.request,0,'None',1,'Null',2,'Row share',
              3,'Row Exclusive',4,'Share',5,'Share Row Exclusive',6,'Exclusive') request_mode,
       c.ctime time_waited
  from  gv$lock b, gv$enqueue_lock c, gv$session a,gv$process p, gv$sql d
 where a.sid = b.sid
   and p.inst_id=a.inst_id
   and a.sql_address = d.address(+)
   and p.addr=a.paddr
   and b.id1 = c.id1(+)
   and b.id2 = c.id2(+)
   and c.type(+) = 'TX'
   and b.type = 'TX'
   and b.block = 1
   order by time_held desc ,time_waited desc;

你可能感兴趣的:(Oracle)