oracle数据库
select t.table_name,t.num_rows from all_tables t; 查询所有表的行数
mysql数据库
use information_schema; 进入information_schema数据库名
select table_name,table_rows from tables where TABLE_SCHEMA = 'sjzx' order by table_rows desc; 查询所有表的行数
问题:oracles数据库存在不准的情况,需要刷新数据表
https://blog.csdn.net/red_sky_blue/article/details/68138845 参考
DXXY 数据库名
select COUNT(*) from xxx ; 查询xxx表的总数
select t.table_name,t.num_rows from all_tables t 查询所有表的总行数
select t.table_name,t.num_rows from all_tables t where table_name ='xxx'; 在所有表中,查询xxx表的总数
select 'analyze table '|| A.TABLE_NAME ||' compute statistics;' from all_tables A where A.OWNER='DXXY'; 将查到的sql,复制出来执行
select 'analyze table ' || A.TABLE_NAME ||' compute statistics for all indexes;' from all_tables A where A.OWNER='DXXY'; 将查到的sql,复制出来执行
select 'analyze table ' || A.TABLE_NAME || ' delete statistics ;' from all_tables A where A.OWNER='DXXY'; 将查到的sql,复制出来执行
例如:analyze 表名 compute statistics;
analyze table KS_GR_MONTH_11_2019 compute statistics; 刷新行数信息
select TABLE_NAME,NUM_ROWS from all_tables A where A.OWNER='DXXY' AND TABLE_NAME ='xxx'; 再次查询 “在所有表中,查询xxx表的总数”