List:MySQL on Win32« Previous MessageNext Message »
From:Paul DuBois Date:June 14 2001 12:48am
Subject:Re: A NOT NULL field can be set to and empty string
View as plain text  
At 3:17 PM +0200 6/13/01, Glenn F. Henriksen wrote:
>Hello.
>
>I just noticed that when I have a table that has a field created with NOT
>NULL (in the example I'm using "clientID" I can set it to NULL with no error
>but it is set to an empty string ( '' ).
>
>This is obviously by design:
>>From the manual chapter 7.7 Create Table syntax:
>"If no DEFAULT value is specified for a column, MySQL automatically assigns
>one. If the column may take NULL as a value, the default value is NULL. If
>the column is declared as NOT NULL, the default value depends on the column
>type:
>   (...)
>   * For string types other than ENUM, the default
>     value is the empty string. (...)"
>
>I found it very confusing that it allowed an empty field when I had
>specified "NOT NULL".

Why?  NULL and the empty string are two distinct values?

>
>Is there any other way to disallow empty fields?
>
>Thank you.
>
>Regards,
>Glenn Henriksen (glenn@stripped)


-- 
Paul DuBois, paul@stripped
Thread
A NOT NULL field can be set to and empty stringGlenn F. Henriksen13 Jun
  • Re: A NOT NULL field can be set to and empty stringPaul DuBois14 Jun
  • RE: A NOT NULL field can be set to and empty stringLuc Van der Veken14 Jun
    • RE: A NOT NULL field can be set to and empty stringTim Endres14 Jun