Home » SQL & PL/SQL » SQL & PL/SQL » datatype of Null (PL SQL)
datatype of Null [message #622267] Sun, 24 August 2014 00:31 Go to next message
smartkadhir
Messages: 1
Registered: July 2014
Location: chennai
Junior Member
Hi,
I want to know the datatype of Null. I Couldn't find it over Internet.This was asked By an Interviewer but am not able to explain. pl help.


Regards.,
K.Kadhir
Re: datatype of Null [message #622268 is a reply to message #622267] Sun, 24 August 2014 00:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

NULL has no datatype.
What is the color of the void?


Re: datatype of Null [message #622269 is a reply to message #622267] Sun, 24 August 2014 00:48 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
smartkadhir wrote on Sat, 23 August 2014 22:31
Hi,
I want to know the datatype of Null. I Couldn't find it over Internet.This was asked By an Interviewer but am not able to explain. pl help.


Regards.,
K.Kadhir


when all else fails, Read The Fine Manual

http://www.oracle.com/pls/db121/search?remark=quick_search&word=null
Re: datatype of Null [message #622275 is a reply to message #622267] Sun, 24 August 2014 01:50 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Discussed here,The Boook Of Null]
icon5.gif  Re: datatype of Null [message #622276 is a reply to message #622267] Sun, 24 August 2014 02:33 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
You can also read some stuff in our OraFAQ wiki. It says, NULL is untyped in SQL.

But there is a simple way to see Oracle assigns varchar2 to a NULL column. When Oracle has no way to determine the strong type, it assigns varchar2 type(eh? to be safe).

Create or replace view my_null_vw as
select null as col from dual
/

Desc my_null_vw


So, in above case Oracle safely assigned varchar2 data type for the NULL. Why? Becuase there was no other way? Oracle made it so...whatever!
Re: datatype of Null [message #622277 is a reply to message #622276] Sun, 24 August 2014 02:45 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
So, in above case Oracle safely assigned varchar2 data type for the NULL. Why? Becuase there was no other way? Oracle made it so...whatever!


Actually this is because Oracle made an equivalence between NULL and empty string, so it is by design.
Otherwise NULL (theoretically) has no datatype in the same way, as I said, the void has no color.

Re: datatype of Null [message #622278 is a reply to message #622267] Sun, 24 August 2014 02:58 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
smartkadhir wrote on Sun, 24 August 2014 11:01
I Couldn't find it over Internet.


It is unbelievable! NULL has had been and still continues to be one of the most discussed, fought, confusing, never ending topic on the web. Which search engine do you use?
Re: datatype of Null [message #622291 is a reply to message #622278] Sun, 24 August 2014 11:03 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Michel,

I completely agree with your elucidation. I had the same thing in my mind. I didn't include it in my post and left an open ended question because, strictly speaking NULL is not even equal to an empty string as per ANSI compliance and the SQL standards, and unlike few RDBMS products which includes it(Oracle being one of them).

Thanks for your reply.
Previous Topic: exists data condition
Next Topic: Use of /*All*/ or /*One*/ at the end of a Query
Goto Forum:
  


Current Time: Wed Apr 24 17:04:03 CDT 2024