Created
March 30, 2011 21:47
-
-
Save dustincurrie/895383 to your computer and use it in GitHub Desktop.
Calculate size of all MySQL databases
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 s.schema_name, CONCAT(IFNULL(ROUND(SUM(t.data_length)/1024/1024,2),0.00),"Mb") as Data_size, | |
CONCAT(IFNULL(ROUND(SUM(t.index_length)/1024/1024,2),0.00),"Mb") as Index_size,COUNT(table_name) total_tables | |
FROM INFORMATION_SCHEMA.SCHEMATA s | |
LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema | |
WHERE s.schema_name not in("mysql","information_schema","test") GROUP BY s.schema_name order by Data_size DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment