An operator in openGauss is a reserved keyword or character, and it is generally used in the WHERE statement as a filter condition. Common operators are as follows:
Arithmetic Operators
· *
Description: Multiplication
Example:
· /
Description: Division (The result is not rounded.)
Example:
· +/-
Description: Positive/Negative
Example:
· %
Description: Model (to obtain the remainder)
Example:
· @
Description: Absolute value
Example:
· ^
Description: Power (exponent calculation)
Example:
· |/
Description: Square root
Example:
· ||/
Description: Cubic root
Example:
· !
Description: Factorial
Example:
· !!
Description: Factorial (prefix operator)
Example:
· &
Description: Binary AND
Example:
· |
Description: Binary OR
Example:
· #
Description: Binary XOR
Example:
· ~
Description: Binary NOT
Example:
· <<
Description: Binary shift left
Example:
· >>
Description: Binary shift right
Example:
Comparison Operators
Comparison operators are available for the most data types and return Boolean values.
All comparison operators are binary operators. Only data types that are the same or that can be implicitly converted can be compared by using comparison operators.
Table 1 describes the comparison operators provided by openGauss.
Table 1 Comparison operators
Comparison operators are available for all relevant data types. All comparison operators are binary operators that returned values of Boolean type. The calculation priority of the inequality sign is higher than that of the equality sign. If the entered data is different and cannot be implicitly converted, the comparison fails. For example, an expression such as 1<2<3 is invalid because the less-than sign (<) cannot be used to compare Boolean values and 3.
Example:
Logical Operators
Common logical operators include AND, OR, and NOT. The operation result can be TRUE, FALSE, or NULL (which means unknown). Their priorities are NOT > AND > OR.
The operators AND and OR are commutative. That is, you can switch the left and right operand without affecting the result.
Table 2 lists the calculation rules, where a and b represent logical expressions.
Table 2 Operation rules
Top comments (0)