Skip site navigation (1) Skip section navigation (2)

Re: multicolumn PRIMARY KEY introduces wrong 'not null' fields

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: laurent(at)bearteam(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: multicolumn PRIMARY KEY introduces wrong 'not null' fields
Date: 2001-08-21 02:11:58
Message-ID: 27063.998359918@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
pgsql-bugs(at)postgresql(dot)org writes:
> If you have a primary key on several columns, each of these columns is
> given the 'not null' modifier. I can't see why this is required.

(A) it makes no sense otherwise, and (B) the SQL spec says so:

         A unique constraint is satisfied if and only if no two rows in
         a table have the same non-null values in the unique columns. In
         addition, if the unique constraint was defined with PRIMARY KEY,
         then it requires that none of the values in the specified column or
         columns be the null value.

If you don't want NOT NULL, maybe what you are after is a plain UNIQUE
constraint, not PRIMARY KEY.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2001-08-21 13:25:58
Subject: Left Join/Outer Join
Previous:From: pgsql-bugsDate: 2001-08-21 01:44:20
Subject: multicolumn PRIMARY KEY introduces wrong 'not null' fields

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group