Script to generate gather table stats for all the tables which dont have upto date statistics

set serveroutput on
set serveroutput on size 1000000
declare
sql_string varchar2(2000);
CURSOR OBJ IS
select owner,table_name
from dba_tables
where last_analyzed is null
–and OWNER=’&owner’
;
begin
for REC1 IN OBJ LOOP
DBMS_OUTPUT.PUT_LINE(‘EXEC DBMS_STATS.GATHER_TABLE_STATS (”’||REC1.owner||”’,”’||REC1.table_name||”’);’);
END LOOP;
END;
/
  • January 20, 2019 | 27 views
  • Comments