Re: Null records inserted - Mailing list pgsql-general

From Tom Lane
Subject Re: Null records inserted
Date
Msg-id 14413.985404827@sss.pgh.pa.us
Whole thread Raw
In response to Null records inserted  (Stephen Davies <scldad@sdc.com.au>)
Responses Re: Null records inserted
List pgsql-general
Stephen Davies <scldad@sdc.com.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

pgsql-general by date:

Previous
From: Ron Peterson
Date:
Subject: Re: HOWTO for pg 7.1 installation from cvs
Next
From: Stephen Davies
Date:
Subject: Re: Null records inserted