Mysql数据库批量更新表编码及排序规则

2023-12-26 10:53:05

SELECT
?? ?CONCAT( 'ALTER TABLE ', TABLE_NAME, ' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' ) AS '修正SQL'?
FROM
?? ?information_schema.`TABLES`?
WHERE
?? ?TABLE_COLLATION != 'utf8mb4_unicode_ci'?
?? ?AND TABLE_SCHEMA = 'edu-integrated';
?? ?
?? ?
SELECT
?? ?CONCAT( 'ALTER TABLE ', TABLE_NAME, ' MODIFY COLUMN `', COLUMN_NAME, '` ', COLUMN_TYPE, ' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' ) AS '修正SQL'?
FROM
?? ?information_schema.`COLUMNS`?
WHERE
?? ?( CHARACTER_SET_NAME != 'utf8mb4' OR COLLATION_NAME != 'utf8mb4_unicode_ci' )?
?? ?AND TABLE_NAME NOT LIKE 'v_%'?
?? ?AND TABLE_SCHEMA = 'edu-integrated';

文章来源:https://blog.csdn.net/zwl18210851801/article/details/135214755
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。