ALTER DATABASE SJZC CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
2.3 修改表的字符集
2.3.1 生成SQL
1 2 3 4 5 6 7 8 9
SELECT CONCAT( 'ALTER TABLE ', table_name, ' CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;' ) FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C WHERE C.collation_name = T.table_collation AND T.table_schema ='SJZC' AND ( C.CHARACTER_SET_NAME !='utf8mb4'OR C.COLLATION_NAME !='utf8mb4_general_ci' );