PostgreSQL - SPLessons

PostgreSQL Operators

Home > Lesson > Chapter 5
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PostgreSQL Operators

PostgreSQL Operators

shape Description

PostgreSQL Operator is a symbol that instructs the compiler to execute some particular logical manipulation and mathematical operation. PostgreSQL Operators contains some of the operators by default, such as:

Arithmetic operator

shape Description

Arithmetic operators execute one or more numeric values and returns the output of a numeric value. The following are the arithmetic PostgreSQL Operators.
Operator Description Example
+ Performs addition of two numbers. A+B, Example 10+5=15.
- Performs subtraction of two numbers. A-B, Example 10-5=5.
* Performs multiplication of two numbers. A*B,Example 10*5=50.
/ Performs division of two numbers. A/B, Example 10/5=2.

Comparison operator

shape Description

Comparison PostgreSQL Operators compares one expression with another, thereby giving a consistent result as NULL, TRUE OR FALSE.
Operator Description Example
= Analyse whether the two values are True or False, if true, then the case will be true. A=B.
< Analyse whether the left value is less than the right value, if true, then the case becomes true. A<B
> Analyse whether the left value is greater than the right value, if true, then the case will be true. A>B
<= Analyse whether the left value is less than or equal to the right value, if yes, then the case becomes true. A<=B
>= Analyse whether the left value is greater than or equal to the right value, if true, then the case becomes true. A>=B

Logical operator

shape Description

Logical PostgreSQL Operators on two operands and returns a boolean value as the output. The accessible logical operators are AND, OR and NOT.
Operator Description
AND It is called as logical AND operator. If two values are true, then the case becomes true.
OR It is called as logical OR operator, suppose any one value is true, then the case become true.
NOT It is called as logical NOT operator, if a case is true, then the logical NOT operator will make it false.

String operator

shape Description

A string is defined as the succession of characters with a discretionary size specifications. The characters can be special characters, letters, numeric, and accumulation of whole sequence or blanks. There are three sorts of strings, for example,

Character large objects

These objects are variable-length strings that range to 128.

Fixed-length strings

While declaring a string, the developer will determine the length. The string is protected with spaces to the length as indicated.

Variable-length strings

The greatest length of variable-length string reaches to 32,767.

String operator

shape Description

These postgreSQL Bitwise operator performs on bits and execute bit by bit executions. And the operation for truth table will be as follows.
p q p&q p|q
0 0 0 0
0 1 0 1
1 1 1 1
1 0 0 1

Summary

shape Key Points

  • PostgreSQL Operator - It is a symbol that instructs the compiler to execute some particular operations.
  • Arithmetic operator - Executes one or more numeric values and returns the result set.
  • Comparison operator - Compares one expression with another.
  • Logical operator - Operates on two operands and returns a boolean output.
  • String operator - A sequence of characters with an discretionary size specifications.
  • Bitwise operator - Executes bit by bit executions.