时间:2021-07-01 10:21:17 帮助过:4人阅读
查询需要更新编码的表字段,并生成相应的更新SQL
SELECT CONCAT(‘ALTER TABLE `‘, table_name, ‘` MODIFY `‘, column_name, ‘` ‘, DATA_TYPE, ‘(‘, CHARACTER_MAXIMUM_LENGTH, ‘)
CHARACTER SET UTF8 COLLATE utf8_bin‘, (CASE WHEN IS_NULLABLE = ‘NO‘ THEN ‘ NOT NULL‘ ELSE ‘‘ END), ‘;‘) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ‘db_name‘ AND DATA_TYPE = ‘varchar‘ AND ( CHARACTER_SET_NAME != ‘utf8‘ OR COLLATION_NAME != ‘utf8_general_ci‘ );
批量更新数据库表以及表字段编码
标签:arc concat lte nbsp select arch case alter info