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
From stackoverflow
-
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**';Mark : Thanks that works too. -
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.
TheSoftwareJedi : or, if you want for each table: SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{your_db}';
0 comments:
Post a Comment