好记忆也需烂 2020-05-09
OK
时间: 0.011s
mysql>alter table test4 add column g varchar(769);
mysql>create index idx_test4_g on test4(g);
create index idx_test4_g on test4(g)
1071 - Specified key was too long; max key length is 3072 bytes
时间: 0.003s
原因:
因为字符串的字符集采用了utf8mb4,一个字符占4个字节,3072/4=768.
结论:
所以,字符串长度最好限制在768之内。