Get size of a specific table in MySQL.
SELECT
table_name AS `Table_Name`,
round(((data_length + index_length) / 1024 / 1024), 2) `Table Size in MB`
FROM
information_schema.TABLES
WHERE
table_schema = '$DATABASE_NAME'
AND table_name = '$TABLE_NAME';
Get size of all tables of a specific schema in MySQL.
SELECT
table_name AS `Table_Name`,
round(((data_length + index_length) / 1024 / 1024), 2) `Table Size in MB`
FROM
information_schema.TABLES
WHERE
table_schema = '$DATABASE_NAME';
Get size of all tables of all schemas in MySQL.
SELECT
table_name AS `Table_Name`,
round(((data_length + index_length) / 1024 / 1024), 2) `Table Size in MB`
FROM
information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
Get size of database in MySQL.
SELECT
table_schema "Schema Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'DataBase Size in MB'
FROM
information_schema.tables
GROUP BY table_schema;