Skip to content

Instantly share code, notes, and snippets.

@bradfordpythian
Last active April 3, 2017 20:46
Show Gist options
  • Save bradfordpythian/d90b91a58d380e6b95819d1afc1abe96 to your computer and use it in GitHub Desktop.
Save bradfordpythian/d90b91a58d380e6b95819d1afc1abe96 to your computer and use it in GitHub Desktop.
MySQL Statement to show schema size and table types
SELECT @@hostname, @@version, @@version_comment, @@version_compile_machine;
SELECT NOW();
SELECT table_schema,
SUM(data_length+index_length)/1024/1024 AS total_mb,
SUM(data_length)/1024/1024 AS data_mb,
SUM(index_length)/1024/1024 AS index_mb,
COUNT(*) AS tables,
CURDATE() AS today
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','sys','performance_schema','information_schema')
GROUP BY table_schema
ORDER BY 2 DESC;
SELECT table_schema,engine,table_collation,
COUNT(*) AS tables
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','sys','performance_schema','information_schema')
GROUP BY table_schema,engine,table_collation;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment