Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
Created September 19, 2016 16:14
Show Gist options
  • Save joshuabaker/658d5b34d1883d91b1538769af0307d8 to your computer and use it in GitHub Desktop.
Save joshuabaker/658d5b34d1883d91b1538769af0307d8 to your computer and use it in GitHub Desktop.
MySQL query that returns tables, row counts, and size in megabytes.
select
`table_schema` as `database`,
`table_name` as `table`,
format(`table_rows`, 0) as `rows`,
format(round(((`data_length` + `index_length`) / 1024 / 1024), 2), 2) as `megabytes`
from `information_schema`.`TABLES`
where `table_schema` != 'information_schema'
order by `database`, `data_length` + `index_length` desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment