Re: PRIMARY KEY on a *group* of columns imply that each

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
Cc: Guy Rouillier <guyr(at)masergy(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PRIMARY KEY on a *group* of columns imply that each
Date: 2005-04-26 20:48:44
Message-ID: 1114548524.13303.1276.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2005-04-26 at 15:39, Stephane Bortzmeyer wrote:
> On Tue, Apr 26, 2005 at 03:22:40PM -0500,
> Guy Rouillier <guyr(at)masergy(dot)com> wrote
> a message of 37 lines which said:
>
> > "The primary key constraint specifies that a column or columns of a
> > table may contain only unique (non-duplicate), nonnull values.
> > Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT
> > NULL"
> >
> > Primary key columns cannot contain null values.
>
> I read the above also. It is perfectly clear for primary key on one
> column.
>
> But it does not apply to primary keys containing a group of
> columns. In that case (my case), columns do not have to be UNIQUE. But
> they have to be NOT NULL, which puzzles me.

Here's a quote from the SQL1992 spec that's VERY clear:

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Gagnon 2005-04-26 20:53:34 How to reduce disk usage and found where disk usage is used? + reindex force doesn`t seem to work
Previous Message Rich Shepard 2005-04-26 20:45:44 Re: blob storage