query snippet bellows finds max length of columns in tables for specific database
SET @database = database();
# SET @database = 'customDatabaseName';
SET group_concat_max_len = 1024*1024;
SET @query = (SELECT CONCAT(GROUP_CONCAT(
CONCAT('(
SELECT \'',COLUMN_NAME,'\' AS `column`,
\'',TABLE_NAME,'\' AS `table_name`,
ROUND(LENGTH(`',COLUMN_NAME,'`) / \'',CHARACTER_MAXIMUM_LENGTH,'\' * 100) AS `utilization`,
\'',CHARACTER_MAXIMUM_LENGTH,'\' AS `max_length`,
LENGTH(`',COLUMN_NAME,'`) AS `length` ',
'FROM `',TABLE_SCHEMA,'`.`',TABLE_NAME,'` ORDER BY `length` DESC LIMIT 1)')
SEPARATOR ' UNION ALL '), ' ORDER BY `utilization` DESC ;') AS _SQL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = @database);
PREPARE stmt1 FROM @query;
EXECUTE stmt1;