Re: Add PK constraint to a Unique Index via updating system catalogs?

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Add PK constraint to a Unique Index via updating system catalogs?
Date: 2014-01-06 22:53:00
Message-ID: lafc3k$kri$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

CS DBA wrote on 06.01.2014 23:30:
> We have a few very large tables with unique indexes on a column but
> the column is not defined as the Primary Key. Can we add a PK
> constraint via updates to the system catalogs so we can avoid the
> lengthy checks that would take place if we ran "alter table add
> constraint primary key...."
>

You can add a PK constraint with the "USING INDEX" clause:

alter table foo
add primary key
using index unique_index_name;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anand Kumar, Karthik 2014-01-07 01:06:40 Sudden slow down and spike in system CPU causes max_connections to get exhausted
Previous Message CS DBA 2014-01-06 22:30:56 Add PK constraint to a Unique Index via updating system catalogs?