操作符
优先级
下表按照从最高优先级到最低优先级的顺序列出了所有InCloud ZNBASE运算符,即它们在语句中的计算顺序。具有相同优先级的运算符是左关联的。这意味着这些运算符从左侧开始向右移动。
优先顺序 | 操作符 | 名称 | 操作符目数 |
---|---|---|---|
1 | . | 成员字段访问运算符 | 双目 |
2 | :: | 类型转换 | 双目 |
3 | - | 自减 | 单目(前缀) |
~ | 按位取反 | 单目(前缀) | |
4 | ^ | 求幂 | 双目 |
5 | 乘 | 双目 | |
/ | 除 | 双目 | |
// | 除(结果向下取整,3/2=1) | 双目 | |
% | 求余 | 双目 | |
6 | + | 加 | 双目 |
- | 减 | 双目 | |
7 | << | 按位左移 | 双目 |
>> | 按位右移 | 双目 | |
8 | & | 按位与 | 双目 |
9 | # | 按位异或 | 双目 |
10 | | | 按位或 | 双目 |
11 | || | 字符串拼接 | 双目 |
< ANY,SOME,ALL | 多值比较 :“小于” | 双目 | |
> ANY,SOME,ALL | 多值比较:“大于” | 双目 | |
= ANY,SOME,ALL | 多值比较: “等于” | 双目 | |
<= ANY,SOME,ALL | 多值比较: “小于或等于” | 双目 | |
>= ANY,SOME,ALL | 多值比较: “大于或等于” | 双目 | |
<> ANY / != ANY,<> SOME / != SOME,<> ALL / != ALL | 多值比较: “不等于” | 双目 | |
[NOT] LIKE ANY,[NOT] LIKE SOME, [NOT] LIKE ALL | 多值比较: LIKE | 双目 | |
[NOT] ILIKE ANY,[NOT] ILIKE SOME,[NOT] ILIKE ALL | 多值比较: ILIKE | 双目 | |
12 | [NOT] BETWEEN | 值不在指定范围 | 双目 |
[NOT] BETWEEN SYMMETRIC | 类似于[NOT] BETWEEN,但未排序。例如,而a BETWEEN b AND c指的是b <= a <= c,a BETWEEN SYMMETRIC b AND c指的是(b <= a <= c) OR (c <= a <= b)。 | 双目 | |
[NOT] IN | 值不在指定的集合中 | 双目 | |
[NOT] LIKE | 匹配[或不匹配] LIKE表达式,区分大小写 | 双目 | |
[NOT] ILIKE | 匹配[或不匹配] LIKE表达式,不区分大小写 | 双目 | |
[NOT] SIMILAR | 匹配[或不匹配] SIMILAR TO正则表达式 | 双目 | |
~ | 匹配正则表达式,区分大小写 | 双目 | |
!~ | 与正则表达式不匹配,区分大小写 | 双目 | |
~ | 匹配正则表达式,不区分大小写 | 双目 | |
!~* | 与正则表达式不匹配,不区分大小写 | 双目 | |
13 | = | 等于 | 双目 |
< | 小于 | 双目 | |
> | 大于 | 双目 | |
<= | 小于或等于 | 双目 | |
>= | 大于或等于 | 双目 | |
!=,<> | 不等于 | 双目 | |
14 | IS [DISTINCT FROM] | 等于,考虑NULL值 | 双目 |
IS NOT [DISTINCT FROM] | 不等于,a IS NOT b相当于NOT(a IS b) | 双目 | |
ISNULL,IS UNKNOWN , NOTNULL, IS NOT UNKNOWN | 等价于 IS NULL/IS NOT NULL | 单目(后缀) | |
IS NAN, IS NOT NAN | 与浮点NAN值的比较 | 单目(后缀) | |
IS OF(…) | 类型谓词(是不是某种类型) | 单目(后缀) | |
15 | NOT | 逻辑非 | 单目 |
16 | AND | 逻辑与 | 双目 |
17 | OR | 逻辑或 | 双目 |
相关支持
支持的操作如下:
操作符 | 表达式 | 返回值 |
---|---|---|
# | int # int | int |
varbit # varbit | varbit | |
#> | jsonb #> string[] | jsonb |
#>> | jsonb #>> string[] | string |
% | decimal % decimal | decimal |
decimal % int | decimal | |
float % float | float | |
int % decimal | decimal | |
int % int | int | |
& | inet & inet | inet |
int & int | int | |
varbit & varbit | varbit | |
&& | anyelement && anyelement | bool |
inet && inet | bool | |
decimal decimal | decimal | |
decimal int | decimal | |
decimal interval | interval | |
float float | float | |
float interval | interval | |
int decimal | decimal | |
int int | int | |
int interval | interval | |
interval decimal | interval | |
interval float | interval | |
interval int | interval | |
+ | date + int | date |
date + interval | timestamptz | |
date + time | timestamp | |
decimal + decimal | decimal | |
decimal + int | decimal | |
float + float | float | |
inet + int | inet | |
int + date | date | |
int + decimal | decimal | |
int + inet | inet | |
int + int | int | |
interval + date | timestamptz | |
interval + interval | interval | |
interval + time | time | |
interval + timestamp | timestamp | |
interval + timestamptz | timestamptz | |
time + date | timestamp | |
time + interval | time | |
timestamp + interval | timestamp | |
timestamptz + interval | timestamptz | |
- | -decimal | decimal |
-float | float | |
-int | int | |
-interval | interval | |
date - date | int | |
date - int | date | |
date - interval | timestamptz | |
date - time | timestamp | |
decimal - decimal | decimal | |
decimal - int | decimal | |
float - float | float | |
inet - inet | int | |
inet - int | inet | |
int - decimal | decimal | |
int - int | int | |
interval - interval | interval | |
jsonb - int | jsonb | |
jsonb - string | jsonb | |
jsonb - string[] | jsonb | |
time - interval | time | |
time - time | interval | |
timestamp - interval | timestamp | |
timestamp - timestamp | interval | |
timestamp - timestamptz | interval | |
timestamptz - interval | timestamptz | |
timestamptz - timestamp | interval | |
timestamptz - timestamptz | interval | |
-> | jsonb -> int | jsonb |
jsonb -> string | jsonb | |
->> | jsonb ->> int | string |
jsonb ->> string | string | |
/ | decimal / decimal | decimal |
decimal / int | decimal | |
float / float | float | |
int / decimal | decimal | |
int / int | decimal | |
interval / float | interval | |
interval / int | interval | |
// | decimal // decimal | decimal |
decimal // int | decimal | |
float // float | float | |
int // decimal | decimal | |
int // int | int | |
< | bool < bool | bool |
bytes < bytes | bool | |
collatedstring < collatedstring | bool | |
date < date | bool | |
date < timestamp | bool | |
date < timestamptz | bool | |
decimal < decimal | bool | |
decimal < float | bool | |
decimal < int | bool | |
float < decimal | bool | |
float < float | bool | |
float < int | bool | |
inet < inet | bool | |
int < decimal | bool | |
int < float | bool | |
int < int | bool | |
interval < interval | bool | |
oid < oid | bool | |
string < string | bool | |
time < time | bool | |
timestamp < date | bool | |
timestamp < timestamp | bool | |
timestamp < timestamptz | bool | |
timestamptz < date | bool | |
timestamptz < timestamp | bool | |
timestamptz < timestamptz | bool | |
tuple < tuple | bool | |
uuid < uuid | bool | |
varbit < varbit | bool | |
<< | inet << inet | bool |
int << int | int | |
varbit << int | varbit | |
<= | bool <= bool | bool |
bytes <= bytes | bool | |
collatedstring <= collatedstring | bool | |
date <= date | bool | |
date <= timestamp | bool | |
date <= timestamptz | bool | |
decimal <= decimal | bool | |
decimal <= float | bool | |
decimal <= int | bool | |
float <= decimal | bool | |
float <= float | bool | |
float <= int | bool | |
inet <= inet | bool | |
int <= decimal | bool | |
int <= float | bool | |
int <= int | bool | |
interval <= interval | bool | |
oid <= oid | bool | |
string <= string | bool | |
time <= time | bool | |
timestamp <= date | bool | |
timestamp <= timestamp | bool | |
timestamp <= timestamptz | bool | |
timestamptz <= date | bool | |
timestamptz <= timestamp | bool | |
timestamptz <= timestamptz | bool | |
tuple <= tuple | bool | |
uuid <= uuid | bool | |
varbit <= varbit | bool | |
<@ | anyelement <@ anyelement | bool |
jsonb <@ jsonb | bool | |
= | bool = bool | bool |
bool[] = bool[] | bool | |
bytes = bytes | bool | |
bytes[] = bytes[] | bool | |
collatedstring = collatedstring | bool | |
date = date | bool | |
date = timestamp | bool | |
date = timestamptz | bool | |
date[] = date[] | bool | |
decimal = decimal | bool | |
decimal = float | bool | |
decimal = int | bool | |
decimal[] = decimal[] | bool | |
float = decimal | bool | |
float = float | bool | |
float = int | bool | |
float[] = float[] | bool | |
inet = inet | bool | |
inet[] = inet[] | bool | |
int = decimal | bool | |
int = float | bool | |
int = int | bool | |
int[] = int[] | bool | |
interval = interval | bool | |
interval[] = interval[] | bool | |
jsonb = jsonb | bool | |
oid = oid | bool | |
string = string | bool | |
string[] = string[] | bool | |
time = time | bool | |
time[] = time[] | bool | |
timestamp = date | bool | |
timestamp = timestamp | bool | |
timestamp = timestamptz | bool | |
timestamp[] = timestamp[] | bool | |
timestamptz = date | bool | |
timestamptz = timestamp | bool | |
timestamptz = timestamptz | bool | |
timestamptz = timestamptz | bool | |
tuple = tuple | bool | |
uuid = uuid | bool | |
uuid[] = uuid[] | bool | |
varbit = varbit | bool | |
>> | inet >> inet | bool |
int >> int | int | |
varbit >> int | varbit | |
? | jsonb ? string | bool |
?& | jsonb ?& string[] | bool |
?| | jsonb ?| string[] | bool |
@> | anyelement @> anyelement | bool |
jsonb @> jsonb | bool | |
ILIKE | string ILIKE string | bool |
IN | bool IN tuple | bool |
bytes IN tuple | bool | |
collatedstring IN tuple | bool | |
date IN tuple | bool | |
decimal IN tuple | bool | |
float IN tuple | bool | |
inet IN tuple | bool | |
int IN tuple | bool | |
interval IN tuple | bool | |
jsonb IN tuple | bool | |
oid IN tuple | bool | |
string IN tuple | bool | |
time IN tuple | bool | |
timestamp IN tuple | bool | |
timestamptz IN tuple | bool | |
tuple IN tuple | bool | |
uuid IN tuple | bool | |
varbit IN tuple | bool | |
IS NOT DISTINCT FROM | bool IS NOT DISTINCT FROM bool | bool |
bool[] IS NOT DISTINCT FROM bool[] | bool | |
bytes IS NOT DISTINCT FROM bytes | bool | |
bytes[] IS NOT DISTINCT FROM bytes[] | bool | |
collatedstring IS NOT DISTINCT FROM collatedstring | bool | |
date IS NOT DISTINCT FROM date | bool | |
date IS NOT DISTINCT FROM timestamp | bool | |
date IS NOT DISTINCT FROM timestamptz | bool | |
date[] IS NOT DISTINCT FROM date[] | bool | |
decimal IS NOT DISTINCT FROM decimal | bool | |
decimal IS NOT DISTINCT FROM float | bool | |
decimal IS NOT DISTINCT FROM int | bool | |
decimal[] IS NOT DISTINCT FROM decimal[] | bool | |
float IS NOT DISTINCT FROM decimal | bool | |
float IS NOT DISTINCT FROM float | bool | |
float IS NOT DISTINCT FROM int | bool | |
float[] IS NOT DISTINCT FROM float[] | bool | |
inet IS NOT DISTINCT FROM inet | bool | |
inet[] IS NOT DISTINCT FROM inet[] | bool | |
int IS NOT DISTINCT FROM decimal | bool | |
int IS NOT DISTINCT FROM float | bool | |
int IS NOT DISTINCT FROM int | bool | |
int[] IS NOT DISTINCT FROM int[] | bool | |
interval IS NOT DISTINCT FROM interval | bool | |
interval[] IS NOT DISTINCT FROM interval[] | bool | |
jsonb IS NOT DISTINCT FROM jsonb | bool | |
oid IS NOT DISTINCT FROM oid | bool | |
string IS NOT DISTINCT FROM string | bool | |
string[] IS NOT DISTINCT FROM string[] | bool | |
time IS NOT DISTINCT FROM time | bool | |
time[] IS NOT DISTINCT FROM time[] | bool | |
timestamp IS NOT DISTINCT FROM date | bool | |
timestamp IS NOT DISTINCT FROM timestamp | bool | |
timestamp IS NOT DISTINCT FROM timestamptz | bool | |
timestamp[] IS NOT DISTINCT FROM timestamp[] | bool | |
timestamptz IS NOT DISTINCT FROM date | bool | |
timestamptz IS NOT DISTINCT FROM timestamp | bool | |
timestamptz IS NOT DISTINCT FROM timestamptz | bool | |
timestamptz IS NOT DISTINCT FROM timestamptz | bool | |
tuple IS NOT DISTINCT FROM tuple | bool | |
unknown IS NOT DISTINCT FROM unknown | bool | |
uuid IS NOT DISTINCT FROM uuid | bool | |
uuid[] IS NOT DISTINCT FROM uuid[] | bool | |
varbit IS NOT DISTINCT FROM varbit | bool | |
LIKE | string LIKE string | bool |
SIMILAR TO | string SIMILAR TO string | bool |
^ | decimal ^ decimal | decimal |
decimal ^ int | decimal | |
float ^ float | float | |
int ^ decimal | decimal | |
int ^ int | int | |
| | inet | inet | inet |
int | int | int | |
varbit | varbit | varbit | |
|| | bool || bool[] | bool[] |
bool[] || bool | bool[] | |
bool[] || bool[] | bool[] | |
bytes || bytes | bytes | |
bytes || bytes[] | bytes[] | |
bytes[] || bytes | bytes[] | |
bytes[] || bytes[] | bytes[] | |
date || date[] | date[] | |
date[] || date | date[] | |
date[] || date[] | date[] | |
decimal || decimal[] | decimal[] | |
decimal[] || decimal | decimal[] | |
decimal[] || decimal[] | decimal[] | |
float || float[] | float[] | |
float[] || float | float[] | |
float[] || float[] | float[] | |
inet || inet[] | inet[] | |
inet[] || inet | inet[] | |
inet[] || inet[] | inet[] | |
int || int[] | int[] | |
int[] || int | int[] | |
int[] || int[] | int[] | |
interval || interval[] | interval[] | |
interval[] || interval | interval[] | |
interval[] || interval[] | interval[] | |
jsonb || jsonb | jsonb | |
oid || oid | oid | |
string || string | string | |
string || string[] | string[] | |
string[] || string | string[] | |
string[] || string[] | string[] | |
time || time[] | time[] | |
time[] || time | time[] | |
time[] || time[] | time[] | |
timestamp || timestamp[] | timestamp[] | |
timestamp[] || timestamp | timestamp[] | |
timestamp[] || timestamp[] | timestamp[] | |
timestamptz || timestamptz | timestamptz | |
timestamptz || timestamptz | timestamptz | |
timestamptz || timestamptz | timestamptz | |
uuid || uuid[] | uuid[] | |
uuid[] || uuid | uuid[] | |
uuid[] || uuid[] | uuid[] | |
varbit || varbit | varbit | |
~ | ~inet | inet |
~int | int | |
~varbit | varbit | |
string ~ string | bool | |
~ | string ~ string | bool |