Skip to content

Instantly share code, notes, and snippets.

@ricardoaugusto
Created November 3, 2021 09:03
Show Gist options
  • Save ricardoaugusto/f31652831a5d39cb0c13f5a40f788e07 to your computer and use it in GitHub Desktop.
Save ricardoaugusto/f31652831a5d39cb0c13f5a40f788e07 to your computer and use it in GitHub Desktop.
Size of tables in a SQL DB. Source: https://stackoverflow.com/a/46143816
SELECT
TABLE_NAME AS `Table`,
ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024),2) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "database_name"
#AND
# TABLE_NAME = "table_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