Converting non-null unique idx to pkey

From: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
To: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Converting non-null unique idx to pkey
Date: 2007-08-21 19:30:10
Message-ID: 200708211330.10288.pgsql@bluepolka.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I'm preparing a fairly large 7.4.6 DB for trigger-based
replication. I'm looking for ways to minimize my impact on the
existing schema & data and uptime. This replication solution
requires every table to have a primary key. Rather than adding
a new key column and index for the pkey, it's appealing to just
to reuse existing unique indices on non-null columns. Are there
are any known or obvious gotchas associated with transforming a
unique index on a non null column into a primary key via this
sql?

update pg_index
set indisprimary = 't'
where indexrelid = <my non-null unique index oid>

TIA.
Ed

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Trutwin 2007-08-21 19:35:23 Re: Array with Subselect / ANY - cast?
Previous Message Robin Helgelin 2007-08-21 19:22:19 Re: history table