Last active
December 26, 2016 12:37
-
-
Save pydevd/d6a54571f88fde26904fb047ea571ef7 to your computer and use it in GitHub Desktop.
This code displays approx size of all databases and tables
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
-- selects approx size of all databases | |
SELECT | |
table_schema AS "Database", | |
SUM( data_length + index_length )/1024/1024 AS "Size, MB" | |
FROM information_schema.TABLES | |
GROUP BY table_schema; | |
SELECT | |
CONCAT(table_schema, '.', table_name) AS "Table", | |
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Total size, MB", | |
ROUND(((data_length) / 1024 / 1024), 2) AS "Data size, MB", | |
ROUND(((index_length) / 1024 / 1024), 2) AS "Index size, MB" | |
FROM information_schema.TABLES | |
WHERE table_schema NOT IN ("information_schema", "mysql"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment