Skip to content

Instantly share code, notes, and snippets.

@ronaldbradford
Created December 20, 2022 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronaldbradford/daf1a53e25feff5e2b6e81b46d6fc276 to your computer and use it in GitHub Desktop.
Save ronaldbradford/daf1a53e25feff5e2b6e81b46d6fc276 to your computer and use it in GitHub Desktop.
Provide a summary of information about MySQL Schemas for a given instance.
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','information_schema','performance_schema','sys','_doit_statpack_mysql')
GROUP BY table_schema
ORDER BY 2 DESC;
SELECT table_schema,engine,table_type, table_collation,
COUNT(*) AS tables
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','information_schema','performance_schema','sys','_doit_statpack_mysql')
GROUP BY table_schema,engine,table_type,table_collation;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment