OceanBase Database supports arithmetic operators, bitwise operators, comparison operators, logical operators, date and time operators, string concatenation operators, and collation operators.
Overview
The following table lists the operators in order of precedence, from highest to lowest. Operators on the same line have the same precedence.
COLLATE
!
- (unary minus), ~ (bitwise NOT)
^
*, /, DIV, %, MOD
-, +
<<, >>
&
|
= (comparison), <=>, >=, >, <=, <, <>, !=
BETWEEN,
NOT
AND, &&
XOR
OR, ||
= (assignment), :=
Considerations
The precedence of
=depends on whether it is used as a comparison operator (=) or an assignment operator (=). When used as a comparison operator, it has the same precedence as<=>,>=,>,<=,<,<>, and!=. When used as an assignment operator, it has the same precedence as:=.When operators with the same precedence appear in an expression, they are evaluated from left to right, except for assignment operators, which are evaluated from right to left.
The precedence and meaning of the following operators depend on the SQL mode:
By default,
||is the logicalORoperator. WhenPIPES_AS_CONCATis enabled,||is used for string concatenation, with precedence between^and unary operators.By default,
!has higher precedence thanNOT. WhenHIGH_NOT_PRECEDENCEis enabled,!andNOThave the same precedence.