Skip to content

Instantly share code, notes, and snippets.

@d0t15t
Created August 30, 2021 09:33
Show Gist options
  • Save d0t15t/fba7bbb230228c189d2161a92c13fbf0 to your computer and use it in GitHub Desktop.
Save d0t15t/fba7bbb230228c189d2161a92c13fbf0 to your computer and use it in GitHub Desktop.
Mysql return tables by size
SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "my_database_name"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment