Manual Logmine


Adds logs and initialize logminer in one plsql block, just using date range.
No need to find specific logs - will error if archivelogs are not available.
Add continuous mine if required to START_LOGMINER call.

Add logs and initialize logminer 


ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

declare
   -- set to 'N' to only mine archived redo logs 
   v_include_online char(1) := 'Y'; 
   v_start date; 
   v_end date; 
begin
  /* keep the date range as small as
   * possible – helps with performance
   */
   v_start := '20-AUG-2019 15:47:00' 
   v_end   := '20-AUG-2019 15:49:10'

  /* find/add relevant logs */
  for i in (
    select rownum r , name 
    from ( select name  from v$archived_log
      where first_time <=  v_start  
      and next_time >= v_end  
      union all 
      select max(member)  from v$logfile
      where v_include_online  = 'Y' 
      group by group#
    )   
  ) loop
    begin 
    if i.r = 1 then
       DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME => i.name,OPTIONS => DBMS_LOGMNR.NEW);
    else
       DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME => i.name,OPTIONS => DBMS_LOGMNR.ADDFILE );
    end if;
    exception when others then  null ;
    end; 
  end loop;
  /*  initialize log miner */
   DBMS_LOGMNR.START_LOGMNR(
       STARTTIME => v_start,
       ENDTIME => v_end ,
       OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG
   );
end;
/

List logs that have been added to mine 

select * from v$logmnr_logs ;


 Mine the logs 

 select * 
from V$LOGMNR_CONTENTS
where  username = '...'
and client_id like '...%'
and table_name in ('...')
and timestamp > '20-AUG-2019 15:47:50' ;



Comments