有没有办法在不对每个表运行 SELECT count()
的情况下获取 MySQL 数据库中所有表中的行数?
Is there a way to get the count of rows in all tables in a MySQL database without running a SELECT count()
on each table?
SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '{your_db}';
文档中的注释: 对于 InnoDB表,行数只是用于 SQL 优化的粗略估计.您需要使用 COUNT(*) 进行精确计数(这更昂贵).
Note from the docs though: For InnoDB tables, the row count is only a rough estimate used in SQL optimization. You'll need to use COUNT(*) for exact counts (which is more expensive).
这篇关于获取 MySQL 数据库中所有表的记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!