【问题标题】:Polish and German accented letters in mysqlmysql中的波兰语和德语重音字母
【发布时间】:2017-04-11 04:28:07
【问题描述】:

我想存储在独特的列波兰语和德国标志。 当我更改数据库时:

alter database osa character set utf8 collate utf8_general_ci;

我对德国标志有疑问。

sql> insert into company(uuid, name) VALUE ("1","IDE")
[2016-11-27 10:37:35] 1 row affected in 13ms

sql> insert into company(uuid, name) VALUE ("2","IDĘ")
[2016-11-27 10:37:37] 1 row affected in 9ms

sql> insert into company(uuid, name) VALUE ("3","Schuring")
[2016-11-27 10:37:38] 1 row affected in 13ms

sql> insert into company(uuid, name) VALUE ("4","Schüring")
[2016-11-27 10:37:39] [23000][1062] Duplicate entry 'Schüring' for key 'UK_niu8sfil2gxywcru9ah3r4ec5'

我必须使用哪种排序规则?

编辑:

也不适用于 utf8_unicode_ci

【问题讨论】:

    标签: mysql utf-8 collation


    【解决方案1】:

    COLLATION 中的_ci 表示“字符不敏感”。不幸的是,它也意味着“口音不敏感”。所以要让E 和Ę 得到不同的处理,你需要一个_bin 排序规则——utf8_bin 或utf8mb4_bin。

    表情符号和中文需要mb4,加上一些晦涩的东西。

    【讨论】:

      【解决方案2】:

      将所有出现的utf8_general_ci 替换为utf8_unicode_ci。 utf8_general_ci 坏了,显然:What are the diffrences between utf8_general_ci and utf8_unicode_ci?

      utf8_general_ci 是一个非常简单的排序规则——在 Unicode 上,非常糟糕——排序规则,它在一般 Unicode 文本上给出不正确的结果。

      【讨论】:

      • 从技术上讲,ut8_unicode_ci 坏了,由 utf8_unicode_520_ci 修复。在 8.0 中,有一个更新的标准:utf8mb4_unicode_900_ci。
      【解决方案3】:

      也许你应该试试 utf8mb4_unicode_ci ?

      Utf8 字符集不能存储所有 utf8 字符。

      https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html

      【讨论】:

      • sql> 插入公司(名称)VALUE(“IDE”)[2016-11-27 22:45:22] 13ms 内影响 1 行 sql> 插入公司(名称)VALUE(“ IDĘ") [2016-11-27 22:45:24] [23000][1062] 键 'UK_name' 的重复条目 'IDĘ'
      • 所有欧洲字符都包含在两个字符集中。
      【解决方案4】:
      alter database osa character set utf8mb4 COLLATE utf8mb4_bin;
      

      为我工作。 @Maciek Bryński 谢谢你的提示。

      【讨论】:

      • bin 做到了,而不是 mb4。
      • @RickJames 完全正确。我知道。
      • 只是为别人澄清一下。
      猜你喜欢
      • 2019-07-02
      • 2011-03-31
      • 1970-01-01
      • 2019-04-02
      • 2018-08-08
      • 1970-01-01
      • 1970-01-01
      • 2013-10-10
      相关资源
      最近更新 更多