Re: Multicolumn primary key with null value

From: Said Ramirez <sramirez(at)vonage(dot)com>
To: Szymon Guz <mabewlun(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multicolumn primary key with null value
Date: 2010-04-22 17:42:16
Message-ID: 4BD08A78.40807@vonage.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Primary keys are defined as 'unique not null' even if they are
composite. So I believe postgres would not let you do that:

5.3.4. Primary Keys

Technically, a primary key constraint is simply a combination of a
unique constraint and a not-null constraint.
....

A primary key indicates that a column or group of columns can be used as
a unique identifier for rows in the table. (This is a direct consequence
of the definition of a primary key. Note that a unique constraint does
not, by itself, provide a unique identifier because it does not exclude
null values.) This is useful both for documentation purposes and for
client applications.

http://www.postgresql.org/docs/8.1/static/ddl-constraints.html

Szymon Guz wrote:
> Does any SQL standard allows for a multicolumn primary key where in one record there is a null in on of the primary key columns?
>
> regards
> Szymon Guz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Morgan Taschuk 2010-04-22 17:42:51 PSQL segmentation fault after setting host
Previous Message Szymon Guz 2010-04-22 17:34:38 Multicolumn primary key with null value