Re: how to add primary key to existing table with multiple

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Daniel Joo <djoo(at)vistagen-inc(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how to add primary key to existing table with multiple
Date: 2006-03-01 02:53:53
Message-ID: 20060228185121.O86334@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 23 Feb 2006, Daniel Joo wrote:

> I am trying to add another primary key to an existing table with two
> other primary keys. I got the following error when I tried this
> command:

You only can have one primary key. The table you gave has a single
primary key with two columns. Are you trying to guarantee that expid
along is unique or that the set (probeid, tissueid, expid) is unique?

You can make expid UNIQUE and NOT NULL for the first case which is similar
to a primary key (although it's not a default foreign key target). In the
second you can drop the current constraint and add one on the three
columns.

> Indexes:
>
> "extprobe2tissue_pkey" PRIMARY KEY, btree (probeid, tissueid)
> "extprobe2tissue_probeid" btree (probeid)
> "extprobe2tissue_tissueid" btree (tissueid)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesemann 2006-03-01 03:05:58 Re: pg reserved words
Previous Message Ken Hill 2006-03-01 01:26:31 Re: Slow update SQL