在mysql中,可以利用SELECT語句配合count()函數(shù)查詢數(shù)據(jù)庫中表的個(gè)數(shù),語法為“SELECT count() FROM information_schema.TABLES WHERE TABLE_SCHEMA='數(shù)據(jù)庫名';”。
本教程操作環(huán)境:windows10系統(tǒng)、mysql8.0.22版本、Dell G3電腦。
mysql怎樣查詢表的個(gè)數(shù)
查看數(shù)據(jù)庫表數(shù)量
語法如下:
SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='dbname';
其中dbname是要查看的數(shù)據(jù)庫的名字。
查看表結(jié)構(gòu):
description tbname;
也可使用簡寫:
desc tbname;
示例如下:
select count(*) tables ,table_schema from information_schema.tables where table_schema='work_ad' group by table_schema;
推薦學(xué)習(xí):mysql視頻教程