·历史归档1 分钟阅读
mysql: how to get tables' count?
愚者·布尔软件 (Bullsoft) 创始人
用MySQL这么久,从来不曾想过查询这个东西,呵呵。。。表多了数不过来了:)
mysql> SELECT COUNT(*) tbls, table_schema dbs FROM information_schema.TABLES GROUP BY table_schema;
+------+--------------------+
| tbls | dbs |
+------+--------------------+
| 1 | cdcol |
| 28 | information_schema |
| 112 | ipboard |
| 29 | miandan |
| 23 | mysql |
| 8 | phpmyadmin |
| 6 | pzblog |
| 2 | test |
| 10 | usions |
+------+--------------------+
9 rows in set (0.02 sec)
mysql> SELECT COUNT(*) tbls, table_schema dbs FROM information_schema.TABLES WHERE table_schema = 'miandan';
+------+---------+
| tbls | dbs |
+------+---------+
| 29 | miandan |
+------+---------+
1 row in set (0.00 sec)