Created
July 1, 2014 14:27
-
-
Save carltondickson/288772c69ce479d99673 to your computer and use it in GitHub Desktop.
Creates SQL that retrieves all tables and row counts for a given schema
This file contains 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 = 'your_db_here'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate many SQL lines such as...
Remember to remove the final UNION piece of SQL.