数据库如何对汉字排序? [英] How do databases sort Chinese characters?

查看:123
本文介绍了数据库如何对汉字排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在编写一个Web应用程序,需要对一组汉字进行一些排序,我想知道汉字是否按数据库排序,如果可以的话,如何对它进行排序?

I am currently writing a web app and will need to do some ordering on a set of Chinese characters and I want to know whether Chinese characters are sorted by databases, if so how does it get sorted?

作为参考,我将使用PostgreSQL。

For reference I will be using PostgreSQL.

推荐答案

PostgreSQL使用操作系统区域设置对文本进行排序设施。这与 sort 之类的操作系统工具所提供的完全相同。因此,在初始化数据库系统时,请将语言环境设置为有用的内容,例如 zh_HK.utf8

PostgreSQL sorts text using the operating system locale facility. This is exactly the same behavior that operating system tools such as sort give you. So set your locale to something useful, such as zh_HK.utf8 when you initialize the database system.

不喜欢这种结果,则必须提供自定义解决方案。

If you don't like the results of that sort, you'll have to come with a custom solution.

这篇关于数据库如何对汉字排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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