在mysql中,如何統(tǒng)計整個數(shù)據(jù)庫中每張表的記錄數(shù)量?
在mysql中,統(tǒng)計某張表中記錄的數(shù)量的方法是
select count(*) from 表名即可
但是,我要統(tǒng)計整個數(shù)據(jù)庫中,每張表的記錄數(shù)量怎么辦?因為這個數(shù)據(jù)庫中有很多張表,如果一條sql語句地寫,太麻煩了,有沒有更簡便的方法。
在mysql中,真有簡便的方法:代碼如下
use information_schema; -- 先打開information_schema
select table_name,table_rows from tables where TABLE_SCHEMA = '數(shù)據(jù)庫名' order by table_rows desc; --查詢表名table_name和數(shù)量table_rows
查詢出來的是每張表的行數(shù)
select count(*) from 表名即可
但是,我要統(tǒng)計整個數(shù)據(jù)庫中,每張表的記錄數(shù)量怎么辦?因為這個數(shù)據(jù)庫中有很多張表,如果一條sql語句地寫,太麻煩了,有沒有更簡便的方法。
在mysql中,真有簡便的方法:代碼如下
use information_schema; -- 先打開information_schema
select table_name,table_rows from tables where TABLE_SCHEMA = '數(shù)據(jù)庫名' order by table_rows desc; --查詢表名table_name和數(shù)量table_rows
查詢出來的是每張表的行數(shù)
中國· 上海

添加微信咨詢
關鍵詞
辦公室:上海市浦東新區(qū)郭守敬路351號
CopyRight?2009-2019 上海谷谷網(wǎng)絡科技有限公司 All Rights Reserved. 滬ICP備11022482號-8
- top
- 在線咨詢
-
添加微信咨詢