Re: Asserting existing key to be primary - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Asserting existing key to be primary
Date
Msg-id 26174.1092425056@sss.pgh.pa.us
Whole thread Raw
In response to Asserting existing key to be primary  (Chris Browne <cbbrowne@acm.org>)
List pgsql-hackers
Chris Browne <cbbrowne@acm.org> writes:
> I have a table that has a candidate primary key (e.g. - unique, not
> null) that I wish to actually assert _is_ a primary key.

> Is there a way to do that without too much (mwahahhaha! fiddling with
> pg_class!!!) trickery?

Why don't you just ALTER TABLE ADD PRIMARY KEY and then drop the
existing unique constraint?

You could probably fool with pg_constraint and pg_index to manually
transform the unique constraint into a pkey constraint, but the odds
of messing it up seem to outweigh the possible time savings.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: hot spare / log shipping work on
Next
From: Tom Lane
Date:
Subject: Re: Referencing OLD/NEW Rows on Trigger Definition