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

Re: converting unique index into primary key

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: converting unique index into primary key
Date: 2004-12-23 03:42:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
"Ed L." <pgsql(at)bluepolka(dot)net> writes:
> I need to convert an existing unique index on a very heavily inserted table 
> into a primary key.  Alter table works, but locks the table for too long.  
> As a hack, can I just set pg_index.indisprimary = 't' and 
> pg_constraint.contype = 'p' for the appropriate row in each?  This is for 
> 7.4.6 and 8.0beta3...

Don't forget to make the underlying columns notnull, too.

			regards, tom lane

In response to

pgsql-general by date

Next:From: Jon AsherDate: 2004-12-23 06:34:24
Subject: Basic problem installing TSearch2 (full text search)
Previous:From: Dann CorbitDate: 2004-12-23 01:18:49
Subject: Re: migrating from mysql

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