Skip to content

Instantly share code, notes, and snippets.

@voigt
Forked from phagedorn/gist:b1f310cdebb7e89c3e54
Created September 29, 2015 08:53
Show Gist options
  • Save voigt/c8a95ecbef22445187c3 to your computer and use it in GitHub Desktop.
Save voigt/c8a95ecbef22445187c3 to your computer and use it in GitHub Desktop.
MySQLL Table size as MB/GB...
SELECT TABLE_NAME AS "Table",
TABLE_ROWS AS "Rows",
CONCAT((FORMAT((DATA_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Data Size",
CONCAT((FORMAT((INDEX_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Index Size",
CONCAT((FORMAT((DATA_LENGTH+ INDEX_LENGTH) / POWER(1024,2),2)), ' Mb') AS "Total Size",
TRIM(TRAILING ', ' FROM CONCAT_WS(', ', ENGINE, TABLE_COLLATION, CREATE_OPTIONS)) AS "Type"
FROM information_schema.TABLES
WHERE information_schema.TABLES.table_schema = "schema_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment