This topic describes the expression syntax.
OceanBase Database uses the following grammar rules to define the expression syntax:
expr:
expr AND expr
| expr && expr
| expr OR expr
| expr || expr
| expr XOR expr
| NOT expr
| bool_pri IS BOOL_VALUE
| bool_pri IS not BOOL_VALUE
| bool_pri IS UNKNOWN
| bool_pri IS not UNKNOWN
| bool_pri := expr
;
bool_pri:
bool_pri IS NULL
| bool_pri IS not NULL
| bool_pri COMP_LE predicate
| bool_pri COMP_LE sub_query_flag '(' select_no_parens ')'
| bool_pri COMP_LT predicate
| bool_pri COMP_LT sub_query_flag '(' select_no_parens ')'
| bool_pri COMP_EQ predicate
| bool_pri COMP_EQ sub_query_flag '(' select_no_parens ')'
| bool_pri COMP_NSEQ predicate
| bool_pri COMP_GE predicate
| bool_pri COMP_GE sub_query_flag '(' select_no_parens ')'
| bool_pri COMP_GT predicate
| bool_pri COMP_GT sub_query_flag '(' select_no_parens ')'
| bool_pri COMP_NE predicate
| bool_pri COMP_NE sub_query_flag '(' select_no_parens ')'
| predicate
;
comparison_operator:
COMP_LE ==> '<='
COMP_LT ==> '<'
COMP_EQ ==> '='
COMP_NSEQ ==> '<=>'
COMP_GE ==> '>='
COMP_GT ==> '>'
COMP_NE ==> '!='
predicate:
bit_expr IN in_expr
| bit_expr not IN in_expr
| bit_expr not BETWEEN bit_expr AND predicate
| bit_expr BETWEEN bit_expr AND predicate
| bit_expr LIKE simple_expr
| bit_expr LIKE simple_expr ESCAPE simple_expr
| bit_expr not LIKE simple_expr
| bit_expr not LIKE simple_expr ESCAPE simple_expr
| bit_expr REGEXP bit_expr
| bit_expr not REGEXP bit_expr
| bit_expr
;
bit_expr:
bit_expr '|' bit_expr
| bit_expr '&' bit_expr
| bit_expr << bit_expr
| bit_expr >> bit_expr
| bit_expr '+' bit_expr
| bit_expr '-' bit_expr
| bit_expr '+' INTERVAL expr date_unit
| bit_expr '-' INTERVAL expr date_unit
| bit_expr '*' bit_expr
| bit_expr '/' bit_expr
| bit_expr '%' bit_expr
| bit_expr MOD bit_expr
| bit_expr DIV bit_expr
| bit_expr '^' bit_expr
| simple_expr
;
simple_expr:
simple_expr collation
| BINARY simple_expr
| column_ref
| expr_const
| simple_expr CNNOP simple_expr
| '+' simple_expr
| '-' simple_expr
| '~' simple_expr
| '!' simple_expr
| not simple_expr
| select_with_parens
| '(' expr ')'
| '(' expr_list ',' expr ')'
| ROW '(' expr_list ',' expr ')'
| EXISTS select_with_parens
| MATCH '(' column_list ')' AGAINST '(' STRING_VALUE opt_mode_flag ')'
| case_expr
| func_expr
| window_function
| USER_VARIABLE
;
For more information about the operator precedence, see Operator precedence.