SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;' ) FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = 'canary';
批量修改表字段字符集
1 2 3 4
SELECT TABLE_SCHEMA '数据库',TABLE_NAME'表',COLUMN_NAME'字段',CHARACTER_SET_NAME '原字符集', COLLATION_NAME '原排序规则', CONCAT('ALTER TABLE ', TABLE_SCHEMA,'.',TABLE_NAME, ' MODIFY COLUMN ',COLUMN_NAME,' ',COLUMN_TYPE,' CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;') '修正SQL' FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = 'canary';