Mysql – Get record counts for all tables in MySQL database

MySQLrowcountsql

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?

Best Answer

SELECT SUM(TABLE_ROWS) 
     FROM INFORMATION_SCHEMA.TABLES 
     WHERE TABLE_SCHEMA = '{your_db}';

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).