Basic Expressions and Operators¶
These building blocks are split into arithmetic and boolean expressions and operators.
Arithmetic Expressions and Operators¶
A SQL developer can use arithmetic operators to construct arithmetic expressions.
10 + 5 is an expression that has two operands (
5) with the addition operator (
+) in between them, which is referred to as infix position.
Another possible position is postfix, which applies, for instance, to the factorial operation, like
Finally, the prefix position is used by, for instance, the bitwise NOT operator, such as
The following table shows the basic operators that ODAS supports.
||Infix||Integer division operator|
||Infix||Bitwise AND operator|
||Infix||Bitwise OR operator|
||Infix||Bitwise XOR operator|
||Prefix||Bitwise NOT operator|
Example: Simple arithmetic expressions
> select 10 * 10; 100 > select 10!; 3628800 > SELECT 5 & ~1; 4
SQL is quite limited in its available operators, but is commonly extended to more complex ones using functions.
Boolean Expressions and Operators¶
In Boolean algebra, instead of using numbers, the allowed values are only
The ODAS supported Boolean operator are shown in the following table, using the same position notation as explained in the previous section.
||Infix||Boolean AND operator|
||Infix||Boolean OR operator|
||Prefix||Boolean NOT operator|
Example: Boolean expressions
> SELECT true AND true; true > SELECT true AND false; false > SELECT (10 < 100) AND ("foo" = "foo"); true