Last active
August 29, 2015 14:17
-
-
Save ryannealmes/71508afec9fc54c9c1f2 to your computer and use it in GitHub Desktop.
Database/Table size in MB
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
You can use this query to show the size of a table: | |
SELECT table_name AS "Table", | |
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" | |
FROM information_schema.TABLES | |
WHERE table_schema = "$DB_NAME" | |
AND table_name = "$TABLE_NAME"; | |
or this query to list the size of every table in the database, largest first: | |
SELECT table_name AS "Tables", | |
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" | |
FROM information_schema.TABLES | |
WHERE table_schema = "$DB_NAME" | |
ORDER BY (data_length + index_length) DESC; | |
Reference: http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment