begin
for x in (select owner,table_name from dba_tables where blocks is null and owner in ('HR'))
loop
execute immediate 'begin DBMS_STATS.UNLOCK_TABLE_STATS('''||x.owner||''','''||x.table_name||''');end;';
execute immediate 'analyze table ' ||x.table_name||' compute statistics';
end loop;
end;
/
当然也可以使用dba_tables或user_tables构造出批量analyze语句脚本,然后执行。
select 'analyze table ' ||table_name||' compute statistics;' from user_tables;
复制出查询结果就是需要执行的脚本。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11411056/viewspace-733354/
,如需转载,请注明出处,否则将追究法律责任。