标签:arc concat lte nbsp select arch case alter info
查询需要更新编码的表,并生成相应的更新SQL
SELECT CONCAT(‘ALTER TABLE ‘, table_name, ‘ CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;‘) FROM information_schema.TABLES WHERE TABLE_SCHEMA = ‘db_name‘ and TABLE_COLLATION != ‘utf8_bin‘
查询需要更新编码的表字段,并生成相应的更新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
原文地址:https://www.cnblogs.com/rhyheart/p/12386412.html