Last active
December 23, 2015 05:49
-
-
Save jeffreyroberts/6590046 to your computer and use it in GitHub Desktop.
MySQL - Generate selects for counting rows of each table in a database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT( | |
'SELECT "', | |
table_name, | |
'" AS table_name, COUNT(*) AS exact_row_count FROM ', | |
table_schema, | |
'.', | |
table_name, | |
' UNION ' | |
) | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE table_schema = '<database_name>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generates output like the following