Skip to content

Instantly share code, notes, and snippets.

@taeram
Last active September 30, 2016 16:51
Show Gist options
  • Save taeram/98b6ea19d779aa1f896309e4e8d39e56 to your computer and use it in GitHub Desktop.
Save taeram/98b6ea19d779aa1f896309e4e8d39e56 to your computer and use it in GitHub Desktop.
MySQL Snippets
-- Table sizes, ordered by Database
SELECT table_schema AS "Database",
table_name AS "Table",
ROUND(((data_length) / 1024 / 1024), 2) AS "Data (MB)",
ROUND(((index_length) / 1024 / 1024), 2) AS "Indexes (MB)",
ROUND(((data_length + index_length) / 1024 / 1024), 2) "Total (MB)"
FROM information_schema.TABLES
WHERE table_schema NOT IN ("information_schema", "mysql")
ORDER BY table_schema ASC, table_name ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment