Wednesday, January 3, 2018

How to check whether table is getting used or not in oracle

To find whether object that is getting used or not please do these little steps to judge...

1) using dba_dependiencies..

select
   owner,
   type,
   name,
   referenced_owner,
   referenced_type,
   referenced_name
from
   dba_dependencies
where
referenced_owner like 'ABC_%'
and referenced_type ='TABLE'
and referenced_name in (
'ABC_123');

2) check any DDL Operations where done.

SELECT TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,INSERTS,UPDATES,DELETES,TRUNCATED,TIMESTAMP FROM dba_TAB_MODIFICATIONS
WHERE TABLE_NAME='TMP_UCL_USER';


3) find any sql's were run from awr snapshots... add columns / make changes as you need.

select
   p.object_name  ,p.sql_id,
   to_char(sn.end_interval_time,'DD-MM')   ,
   count(1)                           
from
  dba_hist_sql_plan   p,
  dba_hist_sqlstat    s,
  dba_hist_snapshot  sn
where
  p.object_owner <> 'SYS' 
and
  p.sql_id = s.sql_id
and
  s.snap_id = sn.snap_id
  and
  sn.end_interval_time between to_date ('20-12-2017 10:00','DD-MM-YYYY HH24:MI')  and to_date ('01-01-2018 19:30','DD-MM-YYYY HH24:MI') and
 --s.executions_delta > 1000
p.object_name in (
 and
s.module not in ('emagent_SQL_oracle_database','emagent_AQMetrics','Oracle Enterprise Manager.Metric Engine')
group by p.object_name, to_char(sn.end_interval_time,'DD-MM'),p.sql_id
order by   2,1;


hope this helps......

No comments:

Post a Comment

PostgreSql: Useful Commands-

 1)   ************************* Users ***************************  -- List of users with roles assigned: SELECT usename AS role_name,   CASE...