An expression is used to calculate a value of data. It consists of one or more numbers, operators, and SQL functions.
Expressions typically use the data types of their components. For example, 2*2 is a simple compound expression that evaluates to 4.
Expressions can be used in multiple locations within an SQL statement, such as in the ORDER BY or HAVING clauses of a SELECT statement, in the WHERE clause of a SELECT, DELETE, or UPDATE statement, or in a SET statement. You can construct expressions using values from various sources, including literals, column values, NULL, variables, built-in functions, and operators.
Here is an example:
obclient> CREATE TABLE t1 (a INT);
obclient> INSERT INTO t1 VALUES (1), (2), (0);
obclient> SELECT ABS(a + 1)
FROM t1
WHERE a > 0;
In the preceding example, the parameters are explained as follows:
ais a column reference.0and1are constants.>and+are operators.ABSis a function.
For the complete syntax hierarchy, see Syntax of Expressions.
The current version of OceanBase AI Database supports the following expression types: