In Oracle SQL, comparison operators are used to compare values in expressions and conditions. These operators help you perform various types of comparisons between values, including equality, inequality, and relative value comparisons. Here’s a brief description of some commonly used comparison operators in Oracle:
1. Equal To Operator (=):
- The equal to operator (=) is used to compare two values for equality. If the values on both sides of the operator are equal, the condition evaluates to TRUE; otherwise, it evaluates to FALSE.
- Example:
salary = 50000
checks if the salary is equal to 50,000.
2. Not Equal To Operator (<>) or (!=):
- The not equal to operator (
<>
) or (!=
) is used to check if two values are not equal. If the values are different, the condition evaluates to TRUE; if they are equal, it evaluates to FALSE. - Example:
age <> 30
checks if the age is not equal to 30.
3. Greater Than Operator (>):
- The greater than operator (
>
) is used to compare two values, and it evaluates to TRUE if the value on the left is greater than the value on the right; otherwise, it evaluates to FALSE. - Example:
score > 90
checks if the score is greater than 90.
4. Less Than Operator (<):
- The less than operator (
<
) is used to compare two values, and it evaluates to TRUE if the value on the left is less than the value on the right; otherwise, it evaluates to FALSE. - Example:
price < 100
checks if the price is less than 100.
5. Greater Than or Equal To Operator (>=):
- The greater than or equal to operator (
>=
) is used to check if the value on the left is greater than or equal to the value on the right. It evaluates to TRUE if the condition is met; otherwise, it evaluates to FALSE. - Example:
quantity >= 50
checks if the quantity is greater than or equal to 50.
6. Less Than or Equal To Operator (<=):
- The less than or equal to operator (
<=
) is used to check if the value on the left is less than or equal to the value on the right. It evaluates to TRUE if the condition is met; otherwise, it evaluates to FALSE. - Example:
rating <= 5
checks if the rating is less than or equal to 5.
These comparison operators are essential for constructing SQL queries and conditions to filter, sort, and retrieve data from Oracle databases. They allow you to express various types of logical conditions and constraints when working with database tables and data.