MySQL怎么查询某个数据库中所有表的记录数
一:明白数据schema的概念
1. 参考 https://database.guide/what-is-a-database-schema/(没有时间看,可以暂时跳过)
2. 数据库连接下information_schema这个库中tables表会记录当前数据库连接下所有表的信息,我们只需要在sql语句中指定具体的database就行.下面附上完整的sql语句:
use information_schema;
select table_name,table_rows from tables where table_schema = '要查询的数据库' order by table_rows asc ;

MySQL查询数据库中所有表记录数的方法
了解数据库schema的概念,可以通过查询information_schema库中的tables表来获取指定数据库的所有表及其记录数。使用如下SQL语句:use information_schema; select table_name, table_rows from tables where table_schema='要查询的数据库' order by table_rows asc; 这将按记录数升序列出所有表。
2265

被折叠的 条评论
为什么被折叠?



