-
Notifications
You must be signed in to change notification settings - Fork 409
Operators
Rene Saarsoo edited this page Oct 21, 2024
·
38 revisions
All dialects support the following standard operators:
-
Arithmetic:
+
,-
,*
,/
-
Comparison:
=
,>
,>=
,<
,<=
,<>
,!=
-
Logical:
AND
,OR
,NOT
,IS
,IS NOT
The standard also defines operators that aren't supported a lot in actual implementations:
-
::
static method invocation -
->
attribute or method reference -
||
string concatenation -
..
embedded Ada and Pascal syntax
Below only additional non-standard operators are listed (the uncommon ones (::
, ->
, ||
, ..
) are assumed to be unsupported unless mentioned otherwise):
- Bitwise:
&
,|
,^
,~
,<<
,>>
-
Comparison:
IS [NOT] DISTINCT FROM
- String/Array concatenation:
||
DB2:
-
Arithmetic:
**
,%
- Bitwise:
&
,|
,^
4,~
-
Comparison:
¬=
,¬>
,!>
,¬<
,!<
,^=
,^<
,^>
- String concatenation:
CONCAT
,||
-
Dereference operation:
->
-
Named arguments:
=>
DB2i:
-
Arithmetic:
**
-
Comparison:
¬=
,¬>
,!>
,¬<
,!<
- String concatenation:
CONCAT
,||
-
Named arguments:
=>
Hive:
- Arithmetic:
%
,DIV
- Bitwise:
~
,^
,|
,&
- Comparison:
==
,<=>
(NULL-safe equal operator) - Logical:
!
- String concatenation:
||
- Arithmetic:
%
,MOD
,DIV
- Assignment:
:=
- Bitwise:
&
,|
,^
,~
,>>
,<<
- Comparison:
<=>
(NULL-safe equal operator) - Logical:
&&
,||
,XOR
,!
- Arithmetic:
%
,MOD
,DIV
- Assignment:
:=
- Bitwise:
&
,|
,^
,~
,>>
,<<
- Comparison:
<=>
(NULL-safe equal operator) - JSON:
->
,->>
- Logical:
&&
,||
,XOR
,!
N1QL:
- Arithmetic:
%
- Comparison:
==
-
Object key-value separator:
:
- String concatenation:
||
- Arithmetic:
**
3 -
Assignment:
:=
- Attribute indicator:
%
-
Comparison:
^=
,~=
3 -
FOR loop range:
..
-
Label delimiters:
<<
,>>
-
Named arguments:
=>
- Remote access indicator:
@
- String concatenation:
||
-
Arithmetic:
%
,^
,|/
(square root),||/
(cube root),@
(abs value) -
Assignment:
:=
-
Bitwise:
&
,|
,#
,~
,>>
,<<
-
Byte comparison:
~>=~
,~<=~
,~>~
,~<~
-
Comparison:
IS [NOT] DISTINCT FROM
-
Geometric:
@-@
,@@
,#
,##
,<->
,@>
,<@
,&&
,<<
,>>
,&<
,&>
,<<|
,|>>
,&<|
,|&>
,<^
,>^
,?#
,?-
,?|
,?-|
,?||
,~=
-
JSON:
->
,->>
,#>
,#>>
,@>
,?
,?|
,?&
,||
,#-
,@?
,@@
-
Named function params:
=>
-
Network address:
<<
,>>
,<<=
,>>=
,&&
,~
,&
,|
-
Pattern matching:
~~
,~~*
,!~~
,!~~*
-
Posix Regex:
~
,~*
,!~
,!~*
-
Range/multirange:
@>
,<@
,&&
,<<
,>>
,&<
,&>
,-|-
, - String concatenation:
||
-
Text search:
@@
,@@@
,||
,&&
,!!
,<->
,@>
,<@
-
Trigram/trigraph:
%
,<%
,%>
,<<%
,%>>
,<->
,<<->
,<->>
,<<<->
,<->>>
-
Type cast:
::
- Arithmetic:
^
,%
,@
(absolute value),|/
(square root)||/
cube root - Bitwise:
&
,|
,#
,~
,<<
,>>
- String concatenation:
||
-
Type cast:
::
-
Assignment:2
:=
-
Bitwise:
&
,|
,^
,~
,>>
,<<
-
Comparison:
<=>
(NULL-safe equal operator) -
JSON:
::
,::$
,::%
- Logical:1
&&
,||
-
Type cast:
:>
,!:>
-
Assignment:
:=
-
Arithmethic:
%
-
Generator:
=>
-
Lambda:
->
-
Path:
:
-
String concatenation:
||
-
Type cast:
::
Same as Hive. Additionally (perhaps also in Hive?):
- Arithmetic:
%
- Bitwise:
~
,&
,|
,<<
,>>
- Comparison:
==
- JSON:
->
,->>
- String concatenation:
||
-
Arithmetic:
%
,MOD
,DIV
-
Assignment:
:=
-
Bitwise:
&
,|
,^
,~
,>>
,<<
-
Comparison:
<=>
(NULL-safe equal operator) -
JSON:
->
,->>
-
Logical:
&&
,||
,XOR
,!
-
Arithmetic:
%
-
Bitwise:
&
,|
,^
,~
-
Comparison:
!<
,!>
-
Compound:
+=
,-=
,*=
,/=
,%=
,&=
,|=
,^=
-
Scope resolution:
::
- Arithmetic:
%
-
Comparison:
IS [NOT] DISTINCT FROM
-
Lambda expression:
->
-
Named arguments:
=>
-
Object key-value separator:
:
-
Row pattern syntax:
+
,|
,*
,?
,$
,(
..)
,{-
..-}
,{n}
,{m,n}
- String concatenation:
||
Notes:
- Tested SingleStoreDB boolean operators manually. Found no docs for these.
- SingleStoreDB only clearly documents the use of
=
operator for assignment, but testing shows that:=
works as well (the docs also contain a lonely example that uses the:=
syntax). - Tested on Oracle Live SQL playground the following operators:
**
,~=
. Both of them produced an error. - Treated as exponentiation when
SQL_COMPAT='NPS'
, normally treated as XOR.