Last active
July 14, 2023 10:26
-
-
Save mrchrisadams/b5cbc56d5465746a9df5449ac260e729 to your computer and use it in GitHub Desktop.
This command, when run in a MySQL compatible database like MariaDB will return a list of all the tables, in descending order of tables size in megabyes.
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_schema as database_name, | |
table_name, | |
round( | |
sum((data_length + index_length + data_free)) / power(1024, 2), | |
2 | |
) as table_size | |
from information_schema.tables | |
where table_schema = 'table_name' -- put your database name here | |
and table_type = 'BASE TABLE' | |
group by table_schema, | |
table_name | |
order by table_size desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment