Re: Null records inserted

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Davies <scldad(at)sdc(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Null records inserted
Date: 2001-03-24 03:33:47
Message-ID: 14413.985404827@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephen Davies <scldad(at)sdc(dot)com(dot)au> writes:
> That is, how can a field that is defined as having a default value wind
> up in the database as null.

Via an explicit specification of a NULL field value in an INSERT.
A default value does not override an explicit specification.

> Despite the usual rules regarding null processing, I would still expect
> a second unique primary key value of null to be rejected.

If you had actually declared it as a primary key (which implies NOT
NULL) then even one null would be disallowed. However a unique
constraint without NOT NULL does not disallow nulls, even multiple ones.
There's been some discussion about whether that's the correct behavior,
but that's how it works at the moment.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Davies 2001-03-24 08:09:34 Re: Null records inserted
Previous Message Ron Peterson 2001-03-24 03:05:52 Re: HOWTO for pg 7.1 installation from cvs