Last Updated: February 25, 2016
·
373
· bor

Calculate sizes for DataBases/Tables

Database sizes

SELECT TABLE_SCHEMA AS "DataBase Name", ROUND(SUM(DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2) AS "Size (in MB)" FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;

Table sizes

SELECT TABLE_NAME, TABLE_ROWS, DATA_LENGTH, INDEX_LENGTH, ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS "Size (in MB)" FROM information_schema.TABLES WHERE TABLE_SCHEMA = "table_name";