List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 7 1999 11:36pm
Subject:Re: why DEFAULT '' when I want not null
View as plain text  
At 5:42 PM -0500 9/7/99, Peter J. Schoenster wrote:
>Hello,
>
>When I try to do this:
>
>title char(50) NOT NULL,
>
>and mysql ends up putting this in:
>
>title char(50) DEFAULT '' NOT NULL,
>
>and so if someone doesn't enter a title, it
>still passes when I want it to fail.
>
>Why does mysql put the DEFAULT '' in there?
>
>If a user puts characters in an int field it is
>automatically coverted to 0.  I would prefer it
>to just fail.


Declaring a character column NOT NULL has nothing to do with whether
or the column can contain an empty string, because an empty string is
different than NULL.

So ... sorry, you're out of luck.  This constraint is something you'll
have to check in your own application logic.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
Can't run isamchk at all.David Stack7 Sep
  • Re: Can't run isamchk at all.Joshua Chamas7 Sep
  • why DEFAULT '' when I want not nullPeter J. Schoenster8 Sep
    • Re: why DEFAULT '' when I want not nullPaul DuBois8 Sep
Re: Can't run isamchk at all.Joshua Chamas8 Sep
  • Re: Can't run isamchk at all.Michael Widenius8 Sep
Re: Can't run isamchk at all.Joshua Chamas8 Sep