What is an Operator in PostgreSQL



An operator is a reserved symbol or word/letter used to do logical or mathematical operations in the PostgreSQL statement.

Types of Operators in PostgreSQL:

1- Arithmetic operators
2- Comparison operators
3- Logical operators
4- Bitwise operators

Arithmetic operators:

+:            Addition, Ex: a+b
-:             Subtraction, Ex: a-b
*:            Multiplication, Ex: a*b
/:             Division, Ex: a/b
%:           Modulus, Ex: a%b
^:            Exponentiation, Ex: a^b
|/:          square root, Ex: |/a
||/:        Cube root, Ex: ||/a
!:             factorial, Ex: !a
!!:           factorial, Ex: !!a

Comparison operators

=:            Equal to operator, Ex:(a = b).
!=:          Not Equal to,Ex: (a != b).
<>:         Not Equal, Ex: (a <> b).
>:            Greater Then, Ex: (a > b).
<:            Less Then, Ex:(a < b).
>=:         Greater Then Equal To, Ex:(a >= b).
<=:         Less Then Equal To, Ex: (a <= b).

Logical operators

AND:     Allows the multiple conditions in a PostgresSQL statement.
NOT:      This is negate operator. NOT EXISTS, NOT BETWEEN, NOT IN, etc.
OR:         Allows to combining multiple conditions in a PostgresSQL statement.

Bitwise operators

||:          concatenation   B'10001' || B'011'             10001011
&:           bitwise AND       B'10001' & B'01101'          00001
|:            bitwise OR          B'10001' | B'01101'           11101
#:            bitwise XOR        B'10001' # B'01101'           11100
~:            bitwise NOT       ~ B'10001'            01110
<<:         bitwise shift left               B'10001' << 3      01000
>>:         bitwise shift right             B'10001' >> 2      00100

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...