是否存在utf8_unicode_cs归类? [英] Does a utf8_unicode_cs collation exist?

查看:49
本文介绍了是否存在utf8_unicode_cs归类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道MySQL的utf8_unicode_cs归类是否存在吗?到目前为止,我的搜索已经干了.如果它根本不存在,创建它是否很简单?还是以某种方式使用utf8_unicode_ci或utf8_bin,但模拟"一个utf8_unicode_cs归类会期望什么?

Does anyone know if a utf8_unicode_cs collation for MySQL exists? So far, my searches have come up dry. If it simply doesn't exist yet, is it fairly straight-forward to create one? Or somehow use utf8_unicode_ci or utf8_bin but "simulate" what one would expect from a utf8_unicode_cs collation?

推荐答案

我遇到了相同的问题,经过一番谷歌搜索后,似乎MySQL不包含它.如您所说,要模拟",

I came across the same issue and after some Googling, it seems that MySQL doesn't include it. To "simulate it", as you put it,

1)要确保数据库中区分大小写,请执行以下操作:将表列设置为utf8_bin排序规则
这允许:

1) To ensure case-sensitivity in the DB: set the table column to utf8_bin collation
This allows:

  • 严格选择:SELECT "Joe"不会返回带有"joe"/"joE"/"jOe"/等的行
  • strict UNIQUE索引:具有UNIQUE索引的列会将大小写差异视为不同的值.例如,如果使用utf8_unicode_ci归类,则在已经具有"joe"的表上插入"Joe"将触发"Duplicate key"错误.如果使用ut8_bin,则插入"Joe"将可以正常工作.
  • strict SELECTs: SELECT "Joe" will NOT return rows with "joe" / "joE" / "jOe" / etc
  • strict UNIQUE index: a column with a UNIQUE index will treat case differences as different values. For example, if a utf8_unicode_ci collation is used, inserting "Joe" on a table that already has "joe" will trigger a "Duplicate key" error. If ut8_bin is used, inserting "Joe" will work fine.

2)要获得正确的结果顺序:将排序规则添加到SQL查询中:

SELECT ... ORDER BY column COLLATE utf8_unicode_ci

这篇关于是否存在utf8_unicode_cs归类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆