Monday, December 12, 2016

Calculate size of mysql databases or tables

Gives size of all Databases

SELECT table_schema AS "DB_NAME",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;

Table Size

SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "DB_NAME_007"
ORDER BY (data_length + index_length) DESC;

No comments:

Post a Comment