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