null constraints and defaults - Mailing list pgsql-general

From elein@varlena.com (elein)
Subject null constraints and defaults
Date
Msg-id 20050629200415.GD7997@varlena.com
Whole thread Raw
Responses Re: null constraints and defaults  (Matt Miller <mattm@epx.com>)
Re: null constraints and defaults  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
It seems that the not null constraint is applied
before the default constraint if a column is
defined with both default and not null.

I understand that default should make the
the NOT NULL constraint unnecessary. But still....

Is this the intended behaviour?


create table nulldefault ( one integer NOT NULL default 1 );
CREATE TABLE
                                 ^
elein=# insert into nulldefault values (NULL);
ERROR:  null value in column "one" violates not-null constraint

elein=# create table defaultnull (one integer default 1);
CREATE TABLE
elein=# insert into defaultnull values (NULL);
INSERT 4681559 1

--elein
elein@varlena.com

pgsql-general by date:

Previous
From: D A GERM
Date:
Subject: Re: Need help writing SQL statement
Next
From: Sven Willenberger
Date:
Subject: Re: PostgreSQL's vacuumdb fails to allocate memory for