~~ Postgres的操作员

时间:2014-02-21 05:13:49

标签: 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)));

~~是什么意思?

2 个答案:

答案 0 :(得分:12)

来自PostgreSQL文档的9.7.1. LIKE

  

运营商~~相当于LIKE~~*对应ILIKE。还有!~~!~~*运算符分别代表NOT LIKENOT ILIKE所有这些运算符都是特定于PostgreSQL的。

答案 1 :(得分:4)

index of the documentation中没有列出令人沮丧的内容。

所以我看一下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)

它是LIKE的运算符别名,这就是全部。