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?
-- 
(format nil "~S@~S" "cbbrowne" "acm.org")
http://cbbrowne.com/info/emacs.html
"What we need is either less corruption, or more chance to participate
in it."  -- Unknown

Thu, 12 Aug 2004 15:14:23 -0400
Chris Browne <cbbrowne@acm.org>
Asserting existing key to be primary
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

Fri, 13 Aug 2004 15:24:16 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Asserting existing key to be primary 