Skip to content

Instantly share code, notes, and snippets.

@isogram
Last active April 18, 2023 05:15
Show Gist options
  • Save isogram/b0dee2f807651f72ea29d2059c160eb6 to your computer and use it in GitHub Desktop.
Save isogram/b0dee2f807651f72ea29d2059c160eb6 to your computer and use it in GitHub Desktop.
Get Database Size MySQL
-- Get Database Size
SELECT
table_schema AS 'Database',
SUM(data_length + index_length) / 1024 / 1024 AS 'Size (MB)'
FROM
information_schema.TABLES
GROUP BY table_schema
-- Get Table Size
SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "bookstore"
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