~~ Postgres的操作员

Isw*_*San 6 postgresql operators

我在Postgres有一个查询:

SELECT DISTINCT a.profn FROM tprof a, sap_tstc b, tgrc c 
WHERE ((c.grcid ~~ a.grcid) 
AND ((c.tcode) = (b.tcode)));
Run Code Online (Sandbox Code Playgroud)

什么~~意思?

Lee*_*hem 13

从9.7.1开始.喜欢 PostgreSQL文档:

运算符~~等同于LIKE,~~*对应于ILIKE.还有!~~和!~~*运营商分别代表NOT LIKE和NOT ILIKE.所有这些运算符都是PostgreSQL特有的.


Cra*_*ger 5

它没有列在令人沮丧的文档索引中.

所以我看了一下psql:

regress=> \do ~~
                                     List of operators
   Schema   | Name | Left arg type | Right arg type | Result type |       Description       
------------+------+---------------+----------------+-------------+-------------------------
 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
(4 rows)
Run Code Online (Sandbox Code Playgroud)

它是运营商的别名LIKE,就是这样.