create table check2(f1 varchar(20),f2 varchar(20));
创建一个默认排序规则为latin1_general_ci
的表;
alter table check2 collate latin1_general_cs;
show full columns from check2;
显示列的单个排序规则为"latin1_general_ci".
那么alter table命令的效果是什么?
create table check2(f1 varchar(20),f2 varchar(20));
创建一个默认排序规则为latin1_general_ci
的表;
alter table check2 collate latin1_general_cs;
show full columns from check2;
显示列的单个排序规则为"latin1_general_ci".
那么alter table命令的效果是什么?
要更改表including those of existing columns的默认字符集和排序规则(请注意convert to子句):
alter table <some_table> convert to character set utf8mb4 collate utf8mb4_unicode_ci;
由于一些 comments 的提示,编辑了答案:
应该避免推荐utf8.它几乎从来都不是你想要的,而且经常会导致意想不到的混乱.utf8字符集与UTF-8不完全兼容.如果你想要UTF-8,utf8mb4字符集就是你想要的Rich Remer 2018年3月28日23:41
和
That seems quite important, glad I read the comments 和 thanks @RichRemer . Nikki , I think you should edit that in your answer considering how many views this gets. See here https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html 和 here What is the difference between utf8mb4 和 utf8 charsets in MySQL? – Paulpro Mar 12 at 17:46