Showing posts with label SQL Null Operations. Show all posts
Showing posts with label SQL Null Operations. Show all posts

Tuesday, October 2, 2018

SQL Null Operations

Null Operations

Null concept in Oracle:-Every null is unique and never equal to another null

Mathematical Concept:-Result will be null on any mathematical operation on null. 
Example:-
null+10=null
null/10=null
null*5=null
null-12=null
That is why every null is unique and never equal to another null

Queries with Null:-
Examples:-
select null+10 from dual;
select null*10 from dual;
select null/5 from dual;
select null-5 from dual;
select null+null from dual;

Result will be null for all above queries.

Oracle Function on null value column:-Every Oracle function treats null values as 0 (by internal nvl function) 
select sum(comm) from emp;

Mathematical Operation without Oracle function:-
Example:-
select sal,comm, sal+comm from emp;

Treating Null value with nvl function:-
Example:-
select sal,comm, sal+nvl(comm,0) from emp;

Data selection from null value column:-

Example:-
select * from emp where comm=null;

Note:-result will be no record this null is never equal to any other null available on column..
Oracle has provided "is" operator for data selection from null values column

Example:-
select * from emp where comm is null;
select * from emp where comm is not null;

SQL Index

Index Index :-  Index is a data structure like table.Index store column data(On which index created) with row identifier rowid.  Databa...