0 votes
1 view
in SQL by (20.3k points)

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?

1 Answer

0 votes
by (40.4k points)

Try this code:

SELECT SUM(TABLE_ROWS)

 FROM INFORMATION_SCHEMA.TABLES      WHERE TABLE_SCHEMA = '{your_db}';

 For InnoDB tables, the row count is only a rough estimate used in SQL optimization.

For exact counts, you can use COUNT(*). But, for InnoDBtables row count is not exactly matched in SQL optimization.

For more information, you can refer to this DOCS.

Related questions

0 votes
1 answer
asked Jul 6, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...