oracle sql and dba tutorial logo

Tutorial for Oracle DBA


Oracle DBA Interview Questions

Most asked Oracle DBA Interview Questions.

60 Technical Questions

42 Backup & Recovery Questions

Unix For Oracle DBA 20 Questions


 

Oracle SQL Tutorial Contents

Introduction to Databases

CODD'S Rules

Datatypes and Create Table

Oracle SELECT Statement

Formatting in SQL*Plus

UNION, INTERSECT, MINUS Operators and Sorting Query Result

 

Oracle ALTER TABLE ADD COLUMN

Oracle ALTER TABLE MODIFY COLUMN

Oracle SQL Functions

Oracle NVL() Function with Examples

Oracle SUBSTR() function with Examples

Oracle TO_DATE() with complete examples

Oracle DECODE function

Oracle INSTR() function with examples

Oracle TO_CHAR() function

Oracle TO_TIMESTAMP

Number Functions (Math Functions)

Character Functions

Miscellaneous Functions

Aggregate Functions

Date and Time Functions

Oracle Join Queries

GROUP BY Queries, SUB Queries

CUBE, ROLLUP Functions

Oracle DML (INSERT, UPDATE, DELETE...)

Oracle DDL (CREATE, ALTER, DROP...)

COMMIT, ROLLBACK,SAVEPOINT

Data Control Language (GRANT, REVOKE)

 

 

Integrity Constraints (PRIMARY KEY, NOT NULL...)

DEFAULT Values

Dropping Constraints

Disabling and Enabling

Differing Constraints Check

View Info about Constraints

Working with Dates

Oracle Views

Oracle Sequences

Oracle Synonyms

Indexes and Clusters

Table Partitioning

Altering Partition Tables

Dropping Partitions

Merging Partitions

Splitting Partitions

Coalescing Partitions

Oracle Objects and Object Types

 

 

 

 

 

 

 

 

 

Oracle NVL function explained with Examples

 

 The NVL() function in Oracle is used to replace NULL / Empty / NA values with some meaningful value. The NVL is a short form for Null Value. As you must be knowing that, NULL value means undefined, empty or Not Assigned. Remember, a blank space is not null and also 0 is not null. Null means undefined value.

So let's get going,

The NVL() function has the following syntax

NVL(exp, replacement-value)

Where the arguments are

exp: The expression which you want to evaluate and want to replace in case it is empty

replacement-value: The value which you want to return if the first argument is empty.

NVL() Examples

For example, suppose we have table: emp, with the following structure

example table for nvl

 

As we can see the COMM column is NULL for some employees.

We can use the NVL function to replace NULL values for COMM with 0 by giving the following command

select empno,ename,job,mgr,hiredate,sal,nvl(comm,0),deptno,city from emp

example of nvl function in oracle

NVL Function a necessity

There are some situations where NVL function becomes essential, like for example, if we need to show the total salary by adding SAL+COMM columns then, if we give the following command we will get the Total salary as NULL for those employees whose COMM is NULL.

example for nvl

In these situations, the NVL function becomes very handy and we can use the NVL function to replace NULL / EMPTY / NA  values with our own value. So to calculate total salary we can give the following command

select empno,ename,sal,comm,(sal+nvl(comm,0)) as Total from emp;

  use of nvl function in calculation

Also see NVL2() function in Oracle

 

 

 

 


HomeContact Us

Data Loader

Data Loader is a simple yet powerful tool to
export and import Data between many common database formats


Forms Data Loader

Tool to load data into Oracle E-Business Suite R12 / Oracle Apps using Macros and Forms Record and Playback

Interface Computers Academy © 2007-2017 All Rights Reserved