@H_404_1@
(最初是
this question的一部分,但它有点无关紧要,所以我决定把它作为自己的问题.)
我找不到运算符〜<〜是什么. Postgres手册仅提及〜和类似的运算符here,但没有〜<〜的迹象. 在psql控制台中摆弄时,我发现这些命令会产生相同的结果:
SELECT * FROM test ORDER BY name USING ~<~; SELECT * FROM test ORDER BY name COLLATE "C";
这些给出了相反的顺序:
SELECT * FROM test ORDER BY name USING ~>~; SELECT * FROM test ORDER BY name COLLATE "C" DESC;
还有关于代字号运算符的一些信息:
\do ~*~ List of operators Schema | Name | Left arg type | Right arg type | Result type | Description ------------+------+---------------+----------------+-------------+------------------------- pg_catalog | ~<=~ | character | character | boolean | less than or equal pg_catalog | ~<=~ | text | text | boolean | less than or equal pg_catalog | ~<~ | character | character | boolean | less than pg_catalog | ~<~ | text | text | boolean | less than pg_catalog | ~>=~ | character | character | boolean | greater than or equal pg_catalog | ~>=~ | text | text | boolean | greater than or equal pg_catalog | ~>~ | character | character | boolean | greater than pg_catalog | ~>~ | text | text | boolean | greater than pg_catalog | ~~ | bytea | bytea | boolean | matches LIKE expression pg_catalog | ~~ | character | text | boolean | matches LIKE expression pg_catalog | ~~ | name | text | boolean | matches LIKE expression pg_catalog | ~~ | text | text | boolean | matches LIKE expression (12 rows)
第3行和第4行是我正在寻找的运算符,但描述对我来说有点不足.
解决方法
〜> =〜,〜< =〜,〜>〜和〜<〜是文本模式(或varchar,基本相同)运算符,它们各自的兄弟姐妹的对应物> =,< =,>和<.他们严格按字节值对字符数据进行排序,忽略任何整理设置的规则(与其兄弟姐妹相对).这使它们更快,但对大多数语言/国家也无效. “C”语言环境实际上与没有语言环境相同,这意味着没有排序规则.这解释了为什么ORDER BY name USING~<〜和ORDER BY name COLLATE“C”最终做同样的事情. 关于dba.SE的相关答案的最后一章的详细说明:
> Pattern matching with LIKE,SIMILAR TO or regular expressions in PostgreSQL
> Pattern matching with LIKE,SIMILAR TO or regular expressions in PostgreSQL
注意~~是用于实现SQL LIKE
expression的Postgres运算符,与上述几乎没有关系.同样,~~ *实现了ILIKE.更多:
> ~~ Operator In Postgres
> Symfony2 Doctrine – ILIKE clause for PostgreSQL?
> PostgreSQL – text Array contains value similar to
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。