postgresql Postgres 中校对的目的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37984264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:19:11  来源:igfitidea点击:

purpose of collate in Postgres

sqlpostgresql

提问by Harnish

I am new to Postgres. I have just started learning it from here. I found COLLATE "C" from a select statement

我是 Postgres 的新手。我刚刚开始从这里学习。我从 select 语句中找到了 COLLATE "C"

SELECT not_equal(first_name, last_name COLLATE "C")

I would like to know what the COLLATE "C" will does?

我想知道 COLLATE "C" 会做什么?

回答by Shayna

Collation is used to sort strings (text), for example by alphabetic order, whether or not case matters, how to deal with letters that have accents etc. COLLATE "C" tells the database not to use collation at all. One might use this if they were designing a database to hold data in different languages. Technically, COLLATE "C" will use byte order to drive text comparisons.

排序规则用于对字符串(文本)进行排序,例如按字母顺序、大小写是否重要、如何处理带重音的字母等。 COLLATE "C" 告诉数据库根本不要使用排序规则。如果他们正在设计一个数据库来保存不同语言的数据,他们可能会使用它。从技术上讲,COLLATE "C" 将使用字节顺序来驱动文本比较。

The first answer on https://dba.stackexchange.com/questions/94887/what-is-the-impact-of-lc-ctype-on-a-postgresql-databaseprovides a good example of the differences between using COLLATE "C" vs. COLLATE "fr_FR" which uses the French localization.

https://dba.stackexchange.com/questions/94887/what-is-the-impact-of-lc-ctype-on-a-postgresql-database上的第一个答案提供了使用 COLLATE 之间差异的一个很好的例子“ C" 与使用法语本地化的 COLLATE "fr_FR"。