Skip to main content

Command Palette

Search for a command to run...

MySQL - How to get database sizes

Published
1 min read
F

I wrote these tutorials for myself in future when I forget for the next steps.

MySQL provides metadata of the database itself, basically just run this on your query. Don't forget to replace database name with yourown database name.

SELECT
  TABLE_NAME AS `Table`,
  ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
  information_schema.TABLES
WHERE
  TABLE_SCHEMA = "replace_with_your_database_name"
ORDER BY
  (DATA_LENGTH + INDEX_LENGTH)
DESC;

Credit, thanks to: https://chartio.com/resources/tutorials/how-to-get-the-size-of-a-table-in-mysql/

More from this blog

F

Fiko Borizqy (Bestafiko)

51 posts

I wrote these tutorials for myself in future when I forget for the next steps.

MySQL - How to get database sizes