MySQL

MySQL useful queries

Check the size of a database:

SELECT table_schema "Database",
sum( data_length + index_length ) / 1024 / 1024 "Size in MB",
FROM information_schema.TABLES
WHERE table_schema = 'DATABASE NAME;'
GROUP BY table_schema;

Truncate multiple tables:

SELECT concat('TRUNCATE TABLE ', TABLE_NAME, ';')
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE 'cache%';

Then, you copy & paste the result into the mysql client.