 New update is available. Click here to update.
Last Updated: Jun 30, 2023

# PL/SQL - Operators

## Introduction

An operator is a symbol instructing the compiler to operate on one or more operands supplied with the symbol. The operand is the variable on which the operation must be performed, and the operator symbol indicates the operation to be performed.

Operators in PL/SQL can be divided into the following categories:

• Arithmetic operators
• Relational operators
• Comparison operators
• Logical operators

Recommended topics, Coalesce in SQL and Tcl Commands in SQL

## Arithmetic Operators

Arithmetic operators are applied to operands to execute various mathematical operations. The various arithmetic operators available in PL/SQL are as follows:

Assume two variables, a and b, respectively, with values of 4 and 2, respectively, to provide examples for each operator.

## Relational Operators

When two values are compared, relational operators return the result as a boolean value ( TRUE or FALSE). They're most commonly employed in situations where a comparison is required. The relational operators available in PL/SQL are as follows:

Let's take two variables, a and b, with values of 6 and 10, respectively, to provide examples for each operator.

## Logical Operators

Logical operators are used to joining two expressions or to define an expression with two operands, and they return True or False depending on the operands or expressions around them.

Assume two variables (or expressions), a and b, with the values false and true, respectively, to provide examples for each operator.

## Comparison Operators

Comparison operators compare two values and return either TRUE, FALSE, or NULL as a result. The different types of comparison operators are as follows:

## Operators Precedence

Operator precedence determines the order in which terms in an expression are grouped. This influences how an expression is evaluated. Certain operators take precedence over others; for example, the multiplication operator takes precedence over the addition operator.

For example, x = 6 + 4 * 3; since operator * has higher precedence than +, x is equal to 18, not 30, and here first multiplication takes place, which is 4*3 before being added to 6.

The precedence of operators goes as follows: =, <, >, <=, >=, <>, !=, ~=, ^=, IS NULL, LIKE, BETWEEN, IN.

Recommended Topic, DCL Commands in SQL

## FAQs

1. What is an operator in PL/SQL?

An operator is a symbol that instructs the compiler to operate on one or more operands supplied with the symbol.

2. What are the different operators available in PL/SQL?

Operators in PL/SQL can be divided into the following categories:

• Arithmetic operators
• Relational operators
• Comparison operators
• Logical operators

3. Write an example for BETWEEN operators?

SELECT * from students WHERE marks BETWEEN 60 AND 100;

## Key Takeaways

In this blog, we have learned that An operator is a symbol that instructs the PL/SQL compiler to operate on one or more operands. The operand is the variable on which the operation must be performed, and the operator symbol indicates the type of operation required for each operand. We have seen various operators available in PL/SQL with examples.

Also, try Coding Ninjas Studio to practice programming problems for your complete interview preparation. Ninja, don't stop here; check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.