Subscribe to Posts by Email

Subscriber Count

    701

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Quick Question: When was the table last modified

Hello All,

In continuation of my previous post,

Quick Question: When is my table last accessed? Does my index is in use?

I have another questions when is my table last modified and what are the ways i can view it.

Here you go,

1) Enabling audit on segment

	1)Enable auditing on table
	2) Use dba_audit_trail to know insert and update statements

2) DBA_TAB_MODIFICATIONS to view the same, statistics_level set to All or Typical
But here are the caevets

  1) If you are in 9i, the data will be pushed from memory to this view 
     every 15 mins
  2) Until 10gr1, the data will be pushed from memory to this view 
     every 3 hours
  3) From 10gr2 onwards this data will be pushed only when you 
     gather statistics on segment 
  4) or manually flush the monitoring info i.e using  
     DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO

Background:- Table/segment modifications used to be monitored using monitoring
on /off on segments on 9i, where this was removed and monitoring is
default in 10g and monitors all object modifications in mon_mod$_all

Another important aspect is, for example, on the below lines

	SQL> Select * from dba_tab_modifications where table_name='TEST';

	TABLE_NAME      INSERTS    UPDATES    DELETES trnc TIMESTAMP                    
	------------ ---------- ---------- ---------- ---- -----------------             
	TEST              320          0          0 NO     26-Mar-2012 10:21     

The date is when the record is entered in the table mon_mod$_all not the exact date
when it modified in the original table.

3) If you have awr license, use dba_hist_sql_stat etc.rather relying on statistics to flush or wait to gather

SQL>
select to_char(sn.begin_interval_time,'yy-mm-dd hh24'),
p.object_owner owners, p.object_name Obj_Name, 
p.operation Operation, 
p.options Options, count(1) Idx_Usg_Cnt 
from dba_hist_sql_plan p,dba_hist_sqlstat s ,  
dba_hist_snapshot sn
where p.object_owner = '&USERNAME'
and p.sql_id = s.sql_id and p.object_name='&OBJNAME' 
and p.operation like '%UPDATE%'
and sn.snap_id = t.snap_id 
group by sn.begin_interval_time,p.object_owner,
p.object_name,p.operation,p.options order by 1,2,3

Note:- I am filtering out the operation as update from sqlstat or sqlplan views 
 
 
 TO_CHAR(SN. OWNERS   OBJ_NAME       OPERATION    
 ----------- ------------ ------------------------
 13-02-26 17 TEST     TEST           UPDATE       
 13-02-26 17 TEST     TEST           UPDATE       
 13-02-27 16 TEST     TEST           UPDATE       
 13-02-27 16 TEST     TEST           UPDATE       
 13-03-02 16 TEST     TEST           UPDATE       
 13-03-02 16 TEST     TEST           UPDATE       
 13-03-02 20 TEST     TEST           UPDATE       
 13-03-02 20 TEST     TEST           UPDATE       
 13-03-07 17 TEST     TEST           UPDATE       
 13-03-07 17 TEST     TEST           UPDATE       
 13-03-08 16 TEST     TEST           UPDATE       
 13-03-08 16 TEST     TEST           UPDATE       
 13-03-08 17 TEST     TEST           UPDATE       
 13-03-08 17 TEST     TEST           UPDATE       
 13-03-09 17 TEST     TEST           UPDATE       
 13-03-09 17 TEST     TEST           UPDATE       
 13-03-12 16 TEST     TEST           UPDATE       
 13-03-12 16 TEST     TEST           UPDATE       
 13-03-14 16 TEST     TEST           UPDATE       
 13-03-14 16 TEST     TEST           UPDATE       
 13-03-14 17 TEST     TEST           UPDATE       
 13-03-14 17 TEST     TEST           UPDATE       
 13-03-16 18 TEST     TEST           UPDATE       
 13-03-16 18 TEST     TEST           UPDATE       
 13-03-19 16 TEST     TEST           UPDATE       
 13-03-19 16 TEST     TEST           UPDATE       
 13-03-20 17 TEST     TEST           UPDATE       
 13-03-20 17 TEST     TEST           UPDATE       
 13-03-21 16 TEST     TEST           UPDATE       

Hope this helps

1 comment to Quick Question: When was the table last modified