Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

analyze tables using procedure .

kumar73Jun 18 2012 — edited Jun 18 2012
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2012
Added on Jun 18 2012
4 comments
877 views