List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 24 1999 8:35pm
Subject:Re: default value
View as plain text  
At 12:48 PM -0500 5/20/99, Harald Seckel wrote:
>Greetings!
>
>I am administrating a MySQL db. Lets say I have a table with column type
>INTEGER. When I insert data MySQL changes any empty cell to "0". But
>this should be "n.a." or something like this.
>
>I tried to set a default value following the tutorial:
>
>CREATE TABLE test (columnA INTEGER NOT NULL DEFAULT 'n.a.')
>
>It doesn't work. :(
>
>I am asking for help. :)


I don't understand your example:

- You define a default value of 'n.a.' which is a string and is not the
  same type as your column (INTEGER)
- It would be possible to set the default to be NULL, and that would
  give you the "not available" meaning you want, but you've declared the
  column NOT NULL.


You can't have the column both be NOT NULL and have a default that means
"not available".  Is there a reason you don't want to use this statement?

CREATE TABLE test (columnA INTEGER DEFAULT NULL)


One reason would be that you want to index columnA.  In that case, you'll
need to choose a "magic value" default that is an integer value you know
you will never insert as real data.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
default valueHarald Seckel20 May
  • Re: default valueGraeme B. Davis20 May
  • Re: default valuePaul DuBois25 May
RE: default valueUnknown Sender20 May
  • Re: default value(Eric Savage)20 May