更新时间:2023-11-26 23:02:34
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).