alter database [$database] character set [$character_set] collate [$collation_name]
注:
[$database]为数据库的库名。
[$character_set]为字符集名称。
[$collation_name]为排序规则名称。
eg:
alter database dbsdq character set utf8mb4 collate utf8mb4_unicode_ci;
alter table [$table] convert to character set [$character_set] collate [$collation_name]
注:
[$table]为表名。
eg:
alter table tt2 convert to character set utf8mb4 collate utf8mb4_unicode_ci;
修改一列:
alter table [$table] modify [$column_name] [$field_type] character set [$character_set] collate [$collation_name]
注:
[$column_name]为字段名。
[$field_type]为字段类型。
eg:
alter table tt2 modify c2 varchar(10) character set utf8mb4 collate utf8mb4_unicode_ci;