PostgreSQL utf8字符比较 [英] PostgreSQL utf8 character comparison

查看:158
本文介绍了PostgreSQL utf8字符比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从MySQL更改为PostgreSQL,但是找不到与MySQL的排序规则 utf8_general_ci 相同的内容。我要在这里实现的目标是能够使用通用语言规则而不是二进制比较来比较字符串,即í= i,š= s,ḩ= h等。

I am changing from MySQL to PostgreSQL but can't find equivalent to MySQL's collation utf8_general_ci. What I'm trying to achieve here is to be able to compare strings using general language rules rather then binary comparison, i.e. í = i, š = s, ḩ = h, etc...

有没有办法让PostgreSQL使用通用语言规则搜索字符串?

Is there a way how to make PostgreSQL search for strings using general language rules?

非常感谢!

推荐答案

基本上,这是大多数现代 postgresql 安装默认情况下将为您完成的工作。但是您可能也对 initdb 选项-locale -lc-collat​​e感兴趣等(大多数(即使不是全部,也可以在使用.conf文件初始化数据库之后进行更改)。)

This is, basically, what most modern postgresql installations will do for you by default. But you may also be interested in initdb options --locale, --lc-collate, etc. (most of those, if not all can also be changed after the database is initialized using .conf file).

您可以创建数据库时,还要指定编码和IIRC LC_COLLATE 和朋友。

You can also specify encoding and IIRC LC_COLLATE and friends when creating database.

这篇关于PostgreSQL utf8字符比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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