Re: null constraints and defaults

From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: Matt Miller <mattm(at)epx(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: null constraints and defaults
Date: 2005-06-29 20:58:28
Message-ID: 20050629205828.GA11836@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 29, 2005 at 01:46:46PM -0700, elein wrote:

[reformatted]

> On Wed, Jun 29, 2005 at 08:25:09PM +0000, Matt Miller wrote:
> > On Wed, 2005-06-29 at 13:04 -0700, elein wrote:
> > > default constraint
> > > ...
> > > elein=# insert into nulldefault values (NULL);
> > > ERROR: null value in column "one" violates not-null constraint
> >
> > I think the idea of a DEFAULT value is to tell the DB what to supply
> > only if you omit the column from the insert statement altogether. If
> > you deliberately call for a NULL, the DB will try to oblige.

> Thanks. I understand that much. I want to know if this
> is the intended behaviour.

Yes; if you want the default value, use DEFAULT instead of NULL. If it
didn't work that way, how would you insert a NULL in the column?

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"Aprende a avergonzarte más ante ti que ante los demás" (Demócrito)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sven Willenberger 2005-06-29 20:58:35 Re: PostgreSQL's vacuumdb fails to allocate memory for
Previous Message Stephan Szabo 2005-06-29 20:50:17 Re: null constraints and defaults