PostgreSQL - Operators

What is an Operator in PostgreSQL?

An operator is a reserved word or a character used primarily in a PostgreSQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations.

Operators are used to specify conditions in a PostgreSQL statement and to serve as conjunctions for multiple conditions in a statement.

  • Arithmetic operators
  • Comparison operators
  • Logical operators
  • Bitwise operators
PostgreSQL Arithmetic Operators

Assume variable a holds 2 and variable b holds 3, then −

Example


PostgreSQL Comparison Operators

Assume variable a holds 10 and variable b holds 20, then −



PostgreSQL Logical Operators

Here is a list of all the logical operators available in PostgresSQL.


PostgreSQL Bit String Operators

Bitwise operator works on bits and performs bit-by-bit operation. The truth table for & and | is as follows −


Assume if A = 60; and B = 13; now in binary format they will be as follows −

A = 0011 1100

B = 0000 1101

-----------------

A&B = 0000 1100

A|B = 0011 1101

~A  = 1100 0011

The Bitwise operators supported by PostgreSQL are listed in the following table −




Comments

Popular posts from this blog

LINUX Move and copy files using SSH

PHP Predefined Variables

Java : Variables Declaring