Skip to main content

Parser

操作符分类

OperatorSymbol
Arithmetic+-*/%
Assignment=,+=,-=,*=,/=,%=
Relational==,!=,>,<,>=,<=
Logical&&,||,!
Unary+,-,++,--,!
Bitwise~,<<,>>,>>>,&,^
Ternary?:
  • Relational - Comparison
  • Logical - Conditional

操作符名字

OperatorabbrName
+addaddition, add, plus, sum
-subsubtraction, sub, minus, difference
+posunary plus, positive, pos
-negunary minus, negative, neg
*mulmultiplication, mul, product, times
/divdivision, div, quotient
%modremainder after division, rem, modulo division, mod
++ --suffix/postfix/prefix increment and decrement
==eqEqual to
gtGreater than
<ltLess than
!=neNot equal to
>=gteGreater than or equal to
<=lteLess than or equal to
&&andLogical AND, Conditional AND
||orLogical OR
!notLogical NOT, Bitwise NOT
xorLogical exclusive OR,Bitwise exclusive OR
??Nullish Coalescing
?.Optional Chaining
&andBitwise AND
|orBitwise OR
&^Bitwise AND NOT - bit clear
~Bitwise complement
<<slBitwise shift left
>>srBitwise shift right
>>>Bitwise unsigned right shift
()parentheses, paren
()callFunction call
[]array subscripting, brackets
{}curly braces
.member access
->member access through pointer
(type)cast
*indirection, dereference, pointer indirection
&address-of
?:Ternary conditional
=Simple assignment
+= -=Assignment by sum and difference
*= /= %=Assignment by product, quotient, and remainder
<<= >>=Assignment by bitwise left shift and right shift
&= ^= |=Assignment by bitwise AND, XOR, and OR
||= &&=Assignment by Logical
??=Logical nullish assignment
<-receive
->send
^, **power, expoentation
...spread, expand
,comma

优先级

PrecedenceOperatordescAssociativity
1++,--suffix/postfixleft to right
()
[]
.
->
(type){list}
2++,--prefixright to left
+ -unary
! ~
(type)cast
*deref
&address of
sizeof
3* / %
4+ -
5<< >>
6< <=
> >=
7== !=
8&bitwise
9bitwise
10|bitwise
11&&and
12||or
13?:ternary
14=
+= -=
*= /=
<<= >>=
&= ^= |=
15,
  • 优先级顺序
    • Unary operators -> Binary operators (MACAO)
      • M - Multiplicative
      • A - Additive
      • C - Comparison
      • A - And
      • O - Or
    • Statement operators - ++,-- - 不考虑在优先级里

SQL Operators

expralias
IS NOT DISTINCT FROMIS
IS DISTINCT FROMIS NOT
IS=
IS NOT!=
Operatordescflavor
AND&&
OR||
===
<>!=
!!=not inPostgresSQL
~~likePostgresSQL
!~~not likePostgresSQL
~regexp
!~not regexp
~*iregexp
!~*not iregexp
!~*not iregexpPostgresSQL
||concatenate strings
[NOT] IN
[NOT] IN [ANY|ALL]PostgresSQL
string [NOT] LIKE pattern [ESCAPE escape-character]
[NOT] LIKE [ANY|ALL]PostgresSQL
[NOT] ILIKE [ANY|ALL]
string [NOT] SIMILAR TO pattern [ESCAPE escape-character]PostgresSQL
[NOT] REGEXPPostgresSQL
[NOT] IREGEXPPostgresSQL
RLIKEMySQL
[NOT] BETWEEN expr AND expr
[NOT] BETWEEN SYMMETRIC expr AND expr自动排序两个值
IS [NOT] (TRUE|FALSE|NULL)
IS [NOT] UNKNOWNUNKNOWN -> NULL
ISNULL
NOTNULL
ARRAY[expr...]
expr::TYPEcast
expr [ANY|SOME|ALL] ( ... )数组比较 - SOME=ANY
row IS [NOT] DISTINCT FROM raw
!factorial
!!factorial (left operator)
%module - 5 % 4
%truncate - % 4.5
:Natural Exponentiation - : 3.0
;Natural Logarithm - (; 5.0)
@absolute - @ -5
Exponentiation - 3.0 ^ 2.0
|/Square root - |/25.0
||/Cube root - ||/27.0
#<,#>,#<=,#>=,#<>,#=interval relation
<#>convert to tine interval
|start of interval
~=same as
<?>time inside interval
& | # ~ << >>Bitewise AND, OR, XOR, NOT, Shift left, Shift rightPostgreSQL
MOD%MySQL
->JSON Extract
->>JSON Extract to Text
Bitwise XORMySQL
Conditionaldesc
CASE WHEN condition THEN result [WHEN...] [ELSE result] END
CASE expr WHEN value THEN result [WHEN...] [ELSE result] END
COALESCE(value [, ...])
NULLIF(value1, value2)
GREATEST(value [, ...])
LEAST(value [, ...])
-- 所有的 operator
SELECT
oprleft,
oprright,
oprresult,
oprcode
FROM
pg_operator;

JSON

Operatordesc
json->integer数组
json->text字段
json->>integer, json->>text返回为 text
json#>text[]提取 path
json#>>text[]提取 为 text
jsonb @> jsonb包含
jsonb <@ jsonb被包含
jsonb ? textkey 存在
jsonb ?| text[]任意 key 存在
jsonb ?& text[]所有 key 存在
jsonb || jsonb合并
jsonb - text删除 key
jsonb - text[]删除 keys
jsonb - integer删除 数组 元素
jsonb #- text[]删除 path 元素
jsonb @? jsonpathJSONPATH 匹配
jsonb @@ jsonpathJSONPATH 匹配 - 必须为 Boolean

Functions