查看行锁持有者对应的SQL【2】

select c.sql_text,
       a.*,
       b.object_name,
       to_date(to_char(c.LAST_active_TIME, 'hh24:mi:ss'), 'hh24:mi:ss') active_time,
       to_date(to_char(sysdate - a.ctime / 24 / 60 / 60, 'HH24:MI:SS'),
               'HH24:MI:SS') as lock_time,
       to_date(to_char(sysdate - a.ctime / 24 / 60 / 60 - 10 / 24 / 60 / 60,
                       'HH24:MI:SS'),
               'HH24:MI:SS') min_time
  from (select sid, id1, ctime
          from v$lock
         where sid in (select sid
                         from v$lock
                        where type in ('TM', 'TX')
                          and lmode = 6)
           and type = 'TM') a,
       dba_objects b,
       v$sqlarea c
 where a.id1 = b.object_id
   and to_date(to_char(c.LAST_active_TIME, 'hh24:mi:ss'), 'hh24:mi:ss') <=
       to_date(to_char(sysdate - a.ctime / 24 / 60 / 60, 'HH24:MI:SS'),
               'HH24:MI:SS')
   and c.PARSING_SCHEMA_NAME = 'TEST'
   and (c.sql_text like '%update%' or c.sql_text like '%delete%' or
       c.sql_text like '%insert%')
   and c.sql_text like '%t100%'
   and to_date(to_char(c.LAST_active_TIME + 10 / 24 / 60 / 60, 'hh24:mi:ss'),
               'hh24:mi:ss') >=
       to_date(to_char(sysdate - a.ctime / 24 / 60 / 60 - 10 / 24 / 60 / 60,
                       'HH24:MI:SS'),
               'HH24:MI:SS')

原文地址:https://www.cnblogs.com/hzcya1995/p/13351998.html