Skip to content

Instantly share code, notes, and snippets.

@aabumuslimov
Created July 19, 2018 20:43
Show Gist options
  • Save aabumuslimov/58ee86e244bbc331084b285fe8a72e27 to your computer and use it in GitHub Desktop.
Save aabumuslimov/58ee86e244bbc331084b285fe8a72e27 to your computer and use it in GitHub Desktop.
(SELECT "DB Total" AS "Table",
ROUND(SUM(data_length) / 1048576) AS "Data",
ROUND(SUM(index_length) / 1048576) AS "Index",
ROUND(SUM(data_length + index_length) / 1048576) AS "Total"
FROM information_schema.TABLES
WHERE table_schema = "7523")
UNION ALL
(SELECT
table_name,
IF(data_length > 0 AND data_length < 104857.6, 0.1, ROUND(data_length / 1048576, 1)),
IF(index_length > 0 AND index_length < 104857.6, 0.1, ROUND(index_length / 1048576, 1)),
IF(data_length + index_length > 0 AND data_length + index_length < 104857.6, 0.1, ROUND((data_length + index_length) / 1048576, 1))
FROM information_schema.TABLES
WHERE table_schema = "7523")
ORDER BY total DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment