Sunday, December 6, 2020

Query to check Table locks history

 select max(sample_time) last_block_time
from gv$active_session_history
--Or use this table for further back.
--from dba_hist_active_sess_history
where blocking_session is not null
    and current_obj# =
    (
        select object_id
        from dba_objects
        where owner = 'JHELLER'       --Enter the object owner here.
            and object_name = 'TEST1' --Enter the object name here.
    );




set pagesize 50
set linesize 120
col sql_id format a15
col inst_id format '9'
col sql_text format a50
col module format a10
col blocker_ses format '999999'
col blocker_ser format '999999'

SELECT  distinct a.sql_id ,a.inst_id,a.blocking_session,a.blocking_session_serial#,a.user_id,s.sql_text,a.module
FROM  GV$ACTIVE_SESSION_HISTORY a  ,gv$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0 —-  exclude SYS user
-- and a.sample_time > sysdate – 7

SELECT  distinct a.sql_id, a.blocking_session,a.blocking_session_serial#,
a.user_id,s.sql_text,a.module
FROM  V$ACTIVE_SESSION_HISTORY a, v$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0
and a.sample_time between to_date('17/06/2011 00:00', 'dd/mm/yyyy hh24:mi')

and to_date('17/06/2011 23:50', 'dd/mm/yyyy hh24:mi');




No comments:

Post a Comment