--exec dbms_stats.gather_schema_stats analyze TABLE test estimate statistics; analyze TABLE test1 estimate statistics; select sum(num_rows) from all_tables where table_name in('test','test1'); analyze TABLE test 成功。 analyze TABLE test1 成功。 SUM(NUM_ROWS) ---------------------- 1 rows selected还是没有结果 不明白为什么 请分析一下 谢谢
如果要多个表的总记录,select sum(NUM_ROWS) from ALL_TABLES where TABLE_NAME in ('TABLE1','TABLE2',...); 一定要大写 如果想看每个表的数据总数:select TABLE_NAME, sum(NUM_ROWS) from ALL_TABLES where TABLE_NAME in ('TABLE1','TABLE2',...) group by TABLE_NAME; 表名,大写哦
接着 select NUM_ROWS from user_tab_statistics;
适用于表数据变化不频繁的情况下
利用这条语句得到的结果是:
SUM(NUM_ROWS)
----------------------
1 rows selected不知道为什么结果不能正确显示
analyze table table1 estimate statistics;
或者同#1的方法这两种都是分析表收集信息。
--exec dbms_stats.gather_schema_stats
analyze TABLE test estimate statistics;
analyze TABLE test1 estimate statistics;
select sum(num_rows)
from all_tables
where table_name in('test','test1'); analyze TABLE test 成功。
analyze TABLE test1 成功。
SUM(NUM_ROWS)
----------------------
1 rows selected还是没有结果
不明白为什么
请分析一下
谢谢
如果想看每个表的数据总数:select TABLE_NAME, sum(NUM_ROWS) from ALL_TABLES where TABLE_NAME in ('TABLE1','TABLE2',...) group by TABLE_NAME;
表名,大写哦