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

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

From: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>,Scott Marlowe <smarlowe(at)g2switchworks(dot)com>,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 column is NOT
Date: 2005-04-27 14:36:49
Message-ID: 20050427143649.GA848@nic.fr (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, Apr 27, 2005 at 10:26:30AM -0400,
 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote 
 a message of 9 lines which said:

> If that's what you want, declare it as UNIQUE not PRIMARY KEY.

As shown by Patrick TJ McPhee, it does not work:

tests=>  create table x (
tests(>    name TEXT NOT NULL,
tests(>    address INET,
tests(>    CONSTRAINT na UNIQUE (name, address)
tests(>  );
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "na" for table "x"
CREATE TABLE
tests=> INSERT INTO x (name) values ('foobar');
INSERT 45380 1
tests=> INSERT INTO x (name) values ('foobar');
INSERT 45381 1
tests=> INSERT INTO x (name) values ('foobar');
INSERT 45382 1
tests=> INSERT INTO x (name) values ('foobar');
INSERT 45383 1
tests=> select * from x;
  name  | address 
--------+---------
 foobar | 
 foobar | 
 foobar | 
 foobar | 
(4 rows)

In response to

Responses

pgsql-general by date

Next:From: Scott MarloweDate: 2005-04-27 14:36:57
Subject: Re: PRIMARY KEY on a *group* of columns imply that each
Previous:From: Scott MarloweDate: 2005-04-27 14:33:22
Subject: Re: PRIMARY KEY on a *group* of columns imply that each

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