Get Size of Tables or Database in MySQL

Get Size of Tables in a single MySQL Database

For a given schema_name (aka database)

SELECT table\_name, table\_rows, data\_length, index\_length,
round(((data\_length + index\_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES
WHERE table\_schema = "schema\_name";

Get Total size of MySQL Databases

SELECT table_schema "Data Base Name",
    sum( data\_length + index\_length) / 1024 / 1024
    "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

Leave a comment

Your email address will not be published. Required fields are marked *