On Fri, 18 Mar 2005, Kenneth Gonsalves wrote:

> On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote:
>
> > Not necessarily. NOT NULL here helps to ensure you can add values
> > together without the risk of a null result. There are plenty of
> > "amount" columns that should be not-null (total spent, total
> > ordered etc).
>
> that makes sense - but is it necessary to have a not null constraint
> when there is a default value?

It's also an added check which prevents you from explicitly setting the
value to NULL in an insert or update, since
"insert into foo(col1) values (NULL);" shouldn't insert the default value
into col1.  This is relatively minor generally, but if you have queries
whose behavior is broken by NULLs (things using IN/NOT IN for example)
it's better to be safe.


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to