The NVL function in Oracle is used to replace the value with NULL. The syntax is NVL(value, default_value). Usage includes: checking and replacing NULL with default value; avoiding calculation and aggregation errors; ensuring database integrity.
Usage of NVL function in Oracle
The NVL function is used in Oracle to replace NULL values to specify default values. . It takes two parameters:
Syntax:
<code>NVL(value, default_value)</code>
Example:
Suppose there is a card named customers
A table with the following columns:
id
(primary key) name
email
If we want to replace "Unknown" with NULL for the email
value, we can use the following query:
<code>SELECT id, name, NVL(email, 'Unknown') AS email FROM customers;</code>
Result:
id | name | |
---|---|---|
1 | John | john@email.com |
2 | Jane | jane@email. com |
3 | Bob | Unknown |
## Usage advantages:
The NVL function is useful in the following situations:Note:
The above is the detailed content of Usage of nvl in oracle. For more information, please follow other related articles on the PHP Chinese website!