mysql查詢表行數(shù)的方法:1、利用“SELECT”語(yǔ)句查詢指定表中的全部數(shù)據(jù);2、使用COUNT()函數(shù)統(tǒng)計(jì)查詢結(jié)果的行數(shù)即可,語(yǔ)法為“SELECT COUNT(*) FROM table_name;”。
本教程操作環(huán)境:windows7系統(tǒng)、mysql8版本、Dell G3電腦。
mysql查詢表的行數(shù)
1.獲取單表的行數(shù)
SELECT COUNT(*) FROM table_name;
2.獲取多表的行數(shù)(可以使用UNION運(yùn)算符組合每個(gè)SELECT語(yǔ)句返回的結(jié)果集)
SELECT 'tablename1' tablename, COUNT(*) rows FROM table_name1UNION SELECT 'tablename2' tablename, COUNT(*) rows FROM table_name2;
3.獲取某個(gè)數(shù)據(jù)庫(kù)的所有表的行數(shù)(information_schema 方法有時(shí)候不準(zhǔn)確)
use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA = 'db.name' order by table_rows desc;
【