通过执行select NUM_ROWS,table_name from user_tables where NUM_ROWSgt;0,是可以达到效果的。但是:有时候数据是不准的,原因
通过执行select NUM_ROWS,table_name from user_tables where NUM_ROWS>0,是可以达到效果的。
但是:有时候数据是不准的,原因是执行该查询的时候要先对表进行分析。
分析表的语法为:analyze table table_name compute statistics;
如何批量对表进行分析呢?
1、存储过程+游标,循环,OK没有问题,但是有点麻烦。
create or replace procedure Pro_AnalyzeTables is
cursor cur_tab is
select table_name from user_tables;
record_cur_tab cur_tab%rowtype;
begin
delete from DataTables;
open cur_tab;
loop
fetch cur_tab into record_cur_tab;
exit when cur_tab%notfound;
execute immediate 'analyze table '||record_cur_tab.table_name||' compute statistics';
end loop;
insert into DataTables (select Table_name,NUM_Rows from user_tables where NUM_ROWS>0);
end Pro_AnalyzeTables;

,
Stellungnahme:Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn