analyze tables using procedure .
kumar73Jun 18 2012 — edited Jun 18 2012Hello Friends,
I my schema , I had to analyze all the tables ( gather statistics ) before I start the loading process to target tables.
I have created a procedure -
create or replace procedure proc_analyze_tables as
table_count number :=0;
sqlstatement varchar2(4000);
begin
for i in ( select TNAME from TAB where TABTYPE='TABLE' AND TNAME ='ABC') loop
sqlstatement := 'ANALYZE TABLE ' || i.TNAME || 'ESTIMATE STATISTICS ';
EXECUTE IMMEDIATE sqlstatement ;
dbms_output.put_line ( 'table name is ' || i.TNAME );
end loop;
end proc_analyze_tables;
is it appropiate to use the folllowing statment.
exec dbms_stats.gather_schema_stats(ownname=>'myschema_name', options=>'GATHER AUTO');
When I execute the procedure , I am getting invalid analyze command .
How I can use the procedure or is their any command that can be executed by execute immediate statement !!
thanks/kumar