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表的總數”