Last active
August 13, 2022 08:48
-
-
Save danishsatkut/596f3837deb07131884813a1a3e78b98 to your computer and use it in GitHub Desktop.
Get database/tables size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM (SELECT table_schema AS `DB Name`, | |
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB` | |
FROM information_schema.tables | |
GROUP BY `DB Name`) AS tmp_table | |
ORDER BY `DB Size in MB` DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
TABLE_NAME AS `Table Name`, | |
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size ( in MB)` | |
FROM | |
information_schema.TABLES | |
WHERE | |
TABLE_SCHEMA = "<db_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