Created
October 20, 2022 14:41
-
-
Save frosit/926b33fd8cb3a4a15736b4d35afe6974 to your computer and use it in GitHub Desktop.
db commands
This file contains hidden or 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
-- get db size | |
SELECT round(Sum(data_length + index_length) / 1024 / 1024, 1) as "Size in MB" FROM information_schema.TABLES WHERE table_schema = database(); | |
-- get sizes of all dbs | |
SELECT table_schema "DB Name", | |
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "MB" | |
FROM | |
information_schema.tables | |
WHERE | |
table_schema NOT IN ( | |
'information_schema', | |
'performance_schema', | |
'mysql' | |
) | |
GROUP BY | |
table_schema | |
ORDER BY | |
MB DESC; | |
-- get sizes of tables in db | |
SELECT TABLE_NAME AS "Table", | |
table_rows AS Rows, | |
round(((data_length + index_length) / 1024 / 1024), 2) AS Size_in_MB | |
FROM | |
information_schema.TABLES | |
WHERE | |
table_schema = database() | |
ORDER BY | |
Size_in_MB DESC | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment