0

I have used to two queries to update one column as NULL:

update table_name 
set col1 = NULL
where col2 = 'MUTHU';

update table_name 
set col1 = ''
where col2 = 'MUTHU';

But when i used to query with function NVL then i am getting the same result for both queries.

select nvl(col1, 'value') from table_name;

My question is: what is the 'difference' and 'use' between NULL and '' ?

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
rcmuthu786
  • 130
  • 1
  • 6

2 Answers2

-1

One difference is that null usually propagates so if you concat null with another string :

create table t
(
  col1 varchar(10),
  col2 varchar(10),
  col3 varchar(10)
  );

insert into t values ( null, '', 'hello' ) ;

select 
 concat(col1 ,col3), 
 concat(col2 ,col3) 
from t

>> NULL, 'hello'
Ian Kenney
  • 6,376
  • 1
  • 25
  • 44
-1

'' implies that the column has a value, which is an empty string

But NULL means “a missing unknown value”

so NULL cannot be compared with =, <= and so on

Sashi Kant
  • 13,277
  • 9
  • 44
  • 71