SELECTt1.TABLE_SCHEMA,t1.TABLE_NAME,t1.COLUMN_NAME,t1.DATA_TYPEFROMINFORMATION_SCHEMA.COLUMNS t1INNER JOIN (-- Subquery: First, find the tables that meet the condition (number of specific-type columns >= 2).SELECTTABLE_SCHEMA,TABLE_NAMEFROMINFORMATION_SCHEMA.COLUMNSWHEREDATA_TYPE IN ('blob', 'mediumblob', 'longblob', 'json', 'text', 'MEDIUMTEXT', 'LONGTEXT', 'geometry')AND TABLE_SCHEMA IN ('xxx', 'xxxx') -- Replace with actual database names.GROUP BYTABLE_SCHEMA,TABLE_NAMEHAVINGCOUNT(*) >= 2) t2 ON t1.TABLE_SCHEMA = t2.TABLE_SCHEMA AND t1.TABLE_NAME = t2.TABLE_NAMEWHERE-- Outer layer filters types again to ensure only risky columns are listed.t1.DATA_TYPE IN ('blob', 'mediumblob', 'longblob', 'json', 'text', 'MEDIUMTEXT', 'LONGTEXT', 'geometry');
SELECTTABLE_SCHEMA,TABLE_NAME,COUNT(*) as risky_column_count,GROUP_CONCAT(COLUMN_NAME) as risky_columns -- Optional: Concatenate column names into a single row for display.FROMINFORMATION_SCHEMA.COLUMNSWHEREDATA_TYPE IN ('blob', 'mediumblob', 'longblob', 'json', 'text', 'MEDIUMTEXT', 'LONGTEXT', 'geometry')AND TABLE_SCHEMA IN ('xxx', 'xxxx')GROUP BYTABLE_SCHEMA,TABLE_NAMEHAVINGCOUNT(*) >= 2;
alter table xx engine = innodb; for repair. To avoid business impact caused by table locking, it is recommended to perform the repair during off-peak hours using tools such as pt-osc.Feedback