Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Created May 16, 2019 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nasrulhazim/57e186666d00897ede6acbb26434236f to your computer and use it in GitHub Desktop.
Save nasrulhazim/57e186666d00897ede6acbb26434236f to your computer and use it in GitHub Desktop.
Get Databases Size in MB and GB
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS size_in_mb,
ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS size_in_gb
FROM information_schema.TABLES
GROUP BY table_schema
order by size_in_gb desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment