MySQL:批量修改表的排序规则

SELECT
CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE,
'(', CHARACTER_MAXIMUM_LENGTH, ') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci',
(CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END),
(case when IFNULL(column_comment,'')='' then '' else concat(' COMMENT \'' , column_comment ,'\'') end),
';') as `sql`
FROM information_schema.COLUMNS
WHERE 1=1
and TABLE_SCHEMA = 'zhnm' #要修改的数据库名称
and DATA_TYPE = 'varchar'
and COLLATION_NAME='utf8mb4_0900_ai_ci'

上一篇:微信小程序打开外部链接


下一篇:量子力学知识点1