Created
November 22, 2021 12:51
-
-
Save ThabetAmer/bcb83c3810323207aa10c91a7136f019 to your computer and use it in GitHub Desktop.
SQL query to list numbers of rows in each table in a db 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
# tested on Mysql 5.7-8 | |
# set database schema name to run against | |
SET @db_name = "DBNAME"; | |
# actual query, two columns resulted: table name and its rows count | |
SELECT | |
TABLE_NAME, | |
SUM(TABLE_ROWS) as c | |
FROM | |
INFORMATION_SCHEMA.TABLES | |
WHERE | |
TABLE_SCHEMA = @db_name | |
group by | |
TABLE_NAME | |
order by | |
c; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment