Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NULL and Empty String

rsar001Feb 17 2011 — edited Feb 18 2011
Hi There,
As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
SQL> CREATE TABLE TS (MID NUMBER,
  2  MDESC VARCHAR2(20) DEFAULT '' NOT NULL);

Table created.

SQL> INSERT INTO TS VALUES(1,'');
INSERT INTO TS VALUES(1,'')
                        *
ERROR at line 1:
ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")
So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!

How come Oracle translates the null string '' as NULL?


Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2011
Added on Feb 17 2011
13 comments
3,313 views