MySql

Mysql get size of tables in a database

To find the detail of size of tables in a database use this query in mysql console:

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;

E.g. for database name mydatabase :

SELECT table_name AS “Tables”,

round(((data_length + index_length) / 1024 / 1024), 2) “Size in MB”

FROM information_schema.TABLES

WHERE table_schema = “mydatabase”

ORDER BY (data_length + index_length) DESC;

You Might Also Like