"utf8_unicode_ci"和"utf8_unicode_520_ci"有什么区别?

27

我最近升级了WAMPServer,现在在phpMyAdmin中,我看到两个排序规则utf8_unicode_ciutf8_unicode_520_ci。我之前在土耳其语应用程序中使用的是"utf8_unicode_ci"排序规则,但我想知道新的*_520排序规则有何不同?


请查看此帖子[22 Aug 2011 16:56] Peter Gulutzan的讨论串http://bugs.mysql.com/bug.php?id=9604。 - user3399549
3个回答

23

1
简而言之?越大越好,没有版本号=最老的版本? - mpen
阅读密钥列表并尝试评估哪一个更适合大多数用户?是的。 - mpen

10
As you can see here (thanks to user3399549 for the link), there is a problem with sorting and comparing the Polish letter "Ł" (L with stroke) (lower case: "ł"; html esc: ł and Ł). In this article, Peter Gulutzan explains the differences between the collations and rules for "Ł":
utf8_polish_ci      Ł greater than L and less than M
utf8_unicode_ci     Ł greater than L and less than M
utf8_unicode_520_ci Ł equal to L
utf8_general_ci     Ł greater than Z

在波兰语中,字母Ł在字母L之后,在字母M之前。为了更清楚地表达,我们可以用以下方式来写:

L < Ł < M 

and 

L != Ł  

为了避免(排序/比较)这种问题,请使用utf8_unicode_ci(或更好的utf8mb4_unicode_ci)。


4
utf8_unicode_520_ciutf8_unicode_ci更新,是吗?为什么会变得更糟呢?作为波兰人,您是否期望在搜索"Stanislaw"时能出现"Stanisław"的结果?当我使用Ctrl+F搜索"L"时,Chrome同时突出显示"Ł"和"L"。 - mpen
选择适合您目的的这个组合。 - Kamil Kiełczewski
1
@mpen 看起来它是作为从general_ci升级路径创建的,而不是作为更好的替代品。 (不要引用我) - lsl

3
如果您只需要土耳其语,可以考虑使用utf8_turkish_ci(或utf8mb4_turkish_ci、utf8mb4_tr_0900_ai_ci、utf8mb4_tr_0900_as_cs)。以下是大部分区别(摘自http://mysql.rjweb.org/utf8_collations.html):
utf8 : utf8_turkish_ci             A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą  Aa  ae          az       Æ=æ
utf8 : utf8_unicode_520_ci         A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą  Aa  ae=Æ=æ      az
utf8 : utf8_unicode_ci             A=a=ª=À=Á=Á=Â=Ã=Ä=Å=à=á=á=â=ã=ä=å=Ā=ā=Ą=ą  Aa  ae          az       Æ=æ

utf8 : utf8_turkish_ci             B=b  C=c=Č=č          ch  cz  Ç=ç  D=d=Ď=ď      dz  Ð=ð
utf8 : utf8_unicode_520_ci         B=b  C=c=Ç=ç=Č=č      ch  cz       D=d=Ð=ð=Ď=ď  dz
utf8 : utf8_unicode_ci             B=b  C=c=Ç=ç=Č=č      ch  cz       D=d=Ď=ď      dz  Ð=ð

utf8 : utf8_turkish_ci             F=f  fz  ƒ  G=g=Ģ=ģ      gz  Ğ=ğ  H=h  hz
utf8 : utf8_unicode_520_ci         F=f  fz  ƒ  G=g=Ğ=ğ=Ģ=ģ  gz       H=h  hz
utf8 : utf8_unicode_ci             F=f  fz  ƒ  G=g=Ğ=ğ=Ģ=ģ  gz       H=h  hz

utf8 : utf8_turkish_ci             I=ı  i=Ì=Í=Í=Î=Ï=ì=í=í=î=ï=Ī=ī=Į=į=İ   ij=ij   iz              J=j
utf8 : utf8_unicode_520_ci         I=i=Ì=Í=Í=Î=Ï=ì=í=í=î=ï=Ī=ī=Į=į=İ      ij=ij   iz           ı  J=j
utf8 : utf8_unicode_ci             I=i=Ì=Í=Í=Î=Ï=ì=í=í=î=ï=Ī=ī=Į=į=İ      ij=ij   iz           ı  J=j

utf8 : utf8_turkish_ci             K=k=Ķ=ķ   L=l=Ĺ=ĺ=Ļ=ļ          lj=LJ=Lj=lj      ll  lz  Ł=ł  M=m  N=n=Ñ=ñ=Ń=ń=Ņ=ņ=Ň=ň  nz
utf8 : utf8_unicode_520_ci         K=k=Ķ=ķ   L=l=Ĺ=ĺ=Ļ=ļ=Ł=ł      lj=LJ=Lj=lj      ll  lz       M=m  N=n=Ñ=ñ=Ń=ń=Ņ=ņ=Ň=ň  nz
utf8 : utf8_unicode_ci             K=k=Ķ=ķ   L=l=Ĺ=ĺ=Ļ=ļ          lj=LJ=Lj=lj      ll  lz  Ł=ł  M=m  N=n=Ñ=ñ=Ń=ń=Ņ=ņ=Ň=ň  nz

utf8 : utf8_turkish_ci             O=o=º=Ò=Ó=Ó=Ô=Õ=ò=ó=ó=ô=õ          oe=Œ=œ      oz  Ö=ö      Ø=ø
utf8 : utf8_unicode_520_ci         O=o=º=Ò=Ó=Ó=Ô=Õ=Ö=Ø=ò=ó=ó=ô=õ=ö=ø  oe=Œ=œ      oz
utf8 : utf8_unicode_ci             O=o=º=Ò=Ó=Ó=Ô=Õ=Ö=ò=ó=ó=ô=õ=ö      oe=Œ=œ      oz           Ø=ø

utf8 : utf8_turkish_ci             P=p  Q=q  R=r=Ř=ř   S=s=Š=Š=š=š        sh  ss=ß  sz  Ş=ş
utf8 : utf8_unicode_520_ci         P=p  Q=q  R=r=Ř=ř   S=s=Ş=ş=Š=Š=š=š    sh  ss=ß  sz
utf8 : utf8_unicode_ci             P=p  Q=q  R=r=Ř=ř   S=s=Ş=ş=Š=Š=š=š    sh  ss=ß  sz

utf8 : utf8_turkish_ci             T=t=Ť=ť  TM=tm=™  tz  U=u=Ù=Ú=Ú=Û=ù=ú=ú=û=Ū=ū=Ů=ů=Ų=ų      ue      uz  Ü=ü      V=v
utf8 : utf8_unicode_520_ci         T=t=Ť=ť  TM=tm=™  tz  U=u=Ù=Ú=Ú=Û=Ü=ù=ú=ú=û=ü=Ū=ū=Ů=ů=Ų=ų  ue      uz           V=v
utf8 : utf8_unicode_ci             T=t=Ť=ť  TM=tm=™  tz  U=u=Ù=Ú=Ú=Û=Ü=ù=ú=ú=û=ü=Ū=ū=Ů=ů=Ų=ų  ue      uz           V=v

utf8 : utf8_turkish_ci             W=w  X=x  Y=y=Ý=Ý=ý=ý=ÿ=Ÿ      yz
utf8 : utf8_unicode_520_ci         W=w  X=x  Y=y=Ý=Ý=ý=ý=ÿ=Ÿ      yz
utf8 : utf8_unicode_ci             W=w  X=x  Y=y=Ý=Ý=ý=ý=ÿ=Ÿ      yz

utf8 : utf8_turkish_ci             Z=z=Ž=Ž=ž=ž  zh  zz           Þ=þ
utf8 : utf8_unicode_520_ci         Z=z=Ž=Ž=ž=ž  zh  zz           Þ=þ
utf8 : utf8_unicode_ci             Z=z=Ž=Ž=ž=ž  zh  zz           Þ=þ

请注意,不同排序规则下Æ、Ç、Ð、Ğ等字母的排序方式不同。
520在普通文本中可能不会产生太大影响,尤其是在土耳其语中。例如,在土耳其语和520中,Ð被视为单独的字母,但utf8_unicode_ci将其视为与D相等。看起来520更接近土耳其语,但对于所有字母而言并非完全相同。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接