Database size of MySQL
SELECT
s.schema_name,
CONCAT(IFNULL(ROUND((SUM(t.data_length) + SUM(t.index_length)) / 1024 / 1024,
2),
0.00),
'Mb') total_size,
CONCAT(IFNULL(ROUND(((SUM(t.data_length) + SUM(t.index_length)) - SUM(t.data_free)) / 1024 / 1024,
2),
0.00),
'Mb') data_used,
CONCAT(IFNULL(ROUND(SUM(data_free) / 1024 / 1024, 2),
0.00),
'Mb') data_free,
IFNULL(ROUND((((SUM(t.data_length) + SUM(t.index_length)) - SUM(t.data_free)) / ((SUM(t.data_length) + SUM(t.index_length))) * 100),
2),
0) pct_used
FROM
INFORMATION_SCHEMA.SCHEMATA s,
INFORMATION_SCHEMA.TABLES t
WHERE
s.schema_name = t.table_schema
AND s.schema_name LIKE 'rp%'
GROUP BY s.schema_name
ORDER BY total_size DESC;
Tags:
Mysql