Created
December 18, 2018 20:36
-
-
Save ivanrosolen/5e3054982034f3ffcec7cf8787dce598 to your computer and use it in GitHub Desktop.
How to get the size of mysql 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
-- All Databases and Tables | |
SELECT | |
table_schema AS `Database`, | |
table_name AS `Table`, | |
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` | |
FROM | |
information_schema.TABLES | |
ORDER BY | |
(data_length + index_length) | |
DESC; | |
-- All Tables from a Database | |
SELECT | |
table_name AS `Table`, | |
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` | |
FROM | |
information_schema.TABLES | |
WHERE | |
table_schema = 'DATABASE_NAME' | |
ORDER BY | |
(data_length + index_length) | |
DESC; | |
-- A table from a Database | |
SELECT | |
table_name AS `Table`, | |
round(((data_length + index_length) / 1024 / 1024),2) `Size in MB` | |
FROM | |
information_schema.TABLES | |
WHERE | |
table_schema = 'DATABASE_NAME' | |
AND table_name = 'TABLE_NAME'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment