Wednesday, October 13, 2010

Gather Statistics in Oracle part 2

-- collect statistics for missing statistics tables


declare
cursor miss_cur IS select table_name from user_tables where last_analyzed is null;
begin
for miss_rec in miss_cur loop
  exit when miss_cur%NOTFOUND;
  dbms_stats.Gather_Table_Stats('SCOTT',miss_rec.table_name,
           estimate_percent => 15,
           method_opt       =>'FOR ALL INDEXED COLUMNS SIZE 1',
           cascade          => TRUE);
  end loop;
end;
/


Hope this help. Regards Rupam