List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:October 11 1999 11:38pm
Subject:Re: NOT NULL => DEFAULT '' NOT NULL ?
View as plain text  
In the last episode (Oct 11), Otis Gospodnetic said:
> Hello,
> 
> If I set no DEFAULT for a varchar column and make it NOT NULL, what should
> happen if I try inserting empty ('') value in that column?
> 
> I expected an error, but when I run this:
> 
> INSERT INTO user_info
> (user_id, user_pass, user_pass_hint, user_fname, user_lname,
>  user_email, user_phone, user_fax, user_addr_1, user_addr_2,
>  user_city, user_state, user_zip, user_country_code)
>  VALUES ('', '', '', '', '', '', '', '', '', '', '', '', '', '')
> 
> The DB took it without an error!  Shouldn't I get an error from a DB
> telling me that I'm inserting a '' value in a column that is varchar
> and NOT NULL?

'' is a zero-length string.  NULL is the absence of a string
altogether.  They are two different things.  Oracle treats them as
equal, but they acknowledge that this isn't right and will treat them
differently in a later version.

-- 
	Dan Nelson
	dnelson@stripped
Thread
NOT NULL => DEFAULT '' NOT NULL ?Otis Gospodnetic12 Oct
  • Re: NOT NULL => DEFAULT '' NOT NULL ?Dan Nelson12 Oct
  • Re: NOT NULL => DEFAULT '' NOT NULL ?Bob Kline12 Oct
RE: NOT NULL => DEFAULT '' NOT NULL ?Otis Gospodnetic12 Oct
  • RE: NOT NULL => DEFAULT '' NOT NULL ?Bob Kline12 Oct
    • RE: NOT NULL => DEFAULT '' NOT NULL ?Otis Gospodnetic12 Oct
      • RE: NOT NULL => DEFAULT '' NOT NULL ?Bob Kline12 Oct