Heya
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?
Cheers
Heya
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?
Cheers
You can probably put something together with Tables table. I've never done it, but it looks like it has a column for *TABLE_ROWS* and one for TABLE NAME.
To get rows per table, you can use a query like this:
SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '**YOUR SCHEMA**';
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.