Re: Problem with NULL values
Posted in 2000
Thomas Parsli <thomas.parsli@startsiden.no> wrote:
>>
>> Unless you have some compelling reason to have nulls in there, I'd fix those columns to disallow nulls and change your application to default to zeroes. Then update the table to set sent to 0 where sent is null.
>
>Fields like this deserves a DEFAULT value _and_ a NOT NULL.
>And I'd rather use -2,147,483,647 as an indicator of "unknown" than
>NULL...
>
>CREATE TABLE orders (
> ...
> quantity INTEGER NOT NULL DEFAULT 0,
> ...
> )>
>Thomas
Allow me to demonstrate my ignorance:
If you alter an existing table to set the NOT NULL and default value will the existing nulls automagically reset to default? I was of the opinion that you still had to update the table to set the existing nulls.
Also, why would you rather use -2,147,483,647 as opposed to NULL in this particular case when the value, when left unspecified, should probably be zero?
Thanks,
carlos
carlos
Currently on hiatus from unemployment.
----------------------
Do you do Linux? :)
Get your FREE @linuxstart.com email address at: http://www.linuxstart.com