最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】mysql中collate中utf8_unicode_ci,utf8_bin,utf8_general_ci的区别

MySQL crifan 4865浏览 0评论

折腾:

【整理】mysql collate 作用

期间,去找找三个的区别。

utf8_unicode_ci vs utf8_bin vs utf8_general_ci

mysql – utf8_bin vs. utf_unicode_ci – Stack Overflow

utf8_bin vs. utf8_general_ci. which collation will provide faster performance in mysql table? – Stack Overflow

mysql中utf8_bin、utf8_general_ci、utf8_general_cs编码区别 – huanleyan的专栏 – 博客频道 – CSDN.NET

mysql – What’s the difference between utf8_general_ci and utf8_unicode_ci – Stack Overflow

MySQL 5.5.3之后,应该用utf8mb4,而不是utf8

不过此处的mysql是5.1.3的,所以还是用utf8:

(RunningFast) ➜  RunningFast mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 604
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

【总结】

  • utf8_bin:用二进制直接比较
  • utf8_general_ci:速度快一点(但是一般来说,性能差距极其小,可以忽略了),但是比较某些特殊的语言和字符时不是足够精确。
  • utf8_unicode_ci:相对比较更加精确

一般来说,最好还是用utf8_unicode_ci

(除非你的CPU性能太低,否则没必要继续再用utf8_general_ci了)

注:

如果是MySQL 5.5.3:

则分别改为:

utf8_general_ci-》utf8mb4_general_ci

utf8_unicode_ci-》utf8mb4_unicode_ci

转载请注明:在路上 » 【整理】mysql中collate中utf8_unicode_ci,utf8_bin,utf8_general_ci的区别

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.180 seconds, using 22.14MB memory