oracle
  1. oracle-is-null-operator

IS NULL Operator - (Oracle Misc)

In Oracle, the NULL value represents a value that is undefined or unknown. The IS NULL operator is used to check whether a value or expression is NULL or not.

Syntax

The syntax for using the IS NULL operator in Oracle is as follows:

SELECT column_name(s)
FROM table_name
WHERE column_name IS NULL;

Here, column_name(s) refers to the column(s) in the table that we want to check for NULL values, and table_name is the name of the table. The WHERE clause filters the results and retrieves only records where the specified column(s) are NULL.

Example

Suppose we have a table called employees that contains information about employees in a company, including their name and phone number. We want to retrieve all records where the phone number is not specified (i.e. NULL).

SELECT name
FROM employees
WHERE phone_number IS NULL;

Output

+------------+
|    name    |
+------------+
| John Smith |
| Jane Doe   |
+------------+

Explanation

In the above example, we select the names of all employees whose phone number is not specified (i.e. NULL). We use the IS NULL operator in the WHERE clause to check for NULL values in the phone_number column. The query returns two records with the names "John Smith" and "Jane Doe", where the phone numbers are NULL.

Use

The IS NULL operator is useful when you want to check for NULL values in a table and retrieve only records where the specified column(s) have NULL values. This operator can be used with any data type, including numeric, character, and date/time types.

Important Points

  • The NULL value in Oracle represents a value that is undefined or unknown.
  • The IS NULL operator is used to check whether a value or expression is NULL or not in Oracle.
  • The IS NULL operator can be used with any data type.
  • The WHERE clause filters the results and retrieves only records where the specified column(s) are NULL.

Summary

In summary, the IS NULL operator in Oracle is used to check for NULL values in a table and retrieve only records where the specified column(s) have NULL values. This operator is easy to use and can be applied to any data type, making it a versatile tool for data querying.

Published on: