Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Determining size of MySQL DB dump and individual tables before dumping it
SELECT
TABLE_SCHEMA,
TABLE_NAME,
DATA_LENGTH / POWER(1024,1) Data_KB,
DATA_LENGTH / POWER(1024,2) Data_MB,
DATA_LENGTH / POWER(1024,3) Data_GB
FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','performance_schema','mysql') ORDER BY DATA_LENGTH;
SELECT
Data_BB / POWER(1024,1) Data_KB,
Data_BB / POWER(1024,2) Data_MB,
Data_BB / POWER(1024,3) Data_GB
FROM (SELECT SUM(data_length) Data_BB FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','performance_schema','mysql')) A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment