pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Ligia Pimentel <lmpimentel@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: An easy question about creating a primary key
Date: Mon, 3 Dec 2001 11:16:14 -0800 (PST)
Message-ID: <20011203111257.H93680-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <9u6gco$7fb$1@news.tht.net>

On Thu, 29 Nov 2001, Ligia Pimentel wrote:

> Hello.
>
> I'm using postgres 7.1. I have an easy question...
>
> I want to create a primary key constraint on an existing table. The
> documentation says I can't . Please confirm. If this is true... How can I
> rename the existing table so I can create the new one and copy the data?

I believe that's correct for 7.1 at least.  You can rename tables using
ALTER TABLE (alter table <table> rename to <newtable>).  If the column(s)
are marked not null already, you may be able to just get away with
creating a unique index on the column(s) named "<table>_pkey"




view thread (13+ messages)  latest in thread

Message-ID: <20011203111257.H93680-100000@megazone23.bigpanda.com>
Permalink:  ../20011203111257.H93680-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20011203111257.H93680-100000@megazone23.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, lmpimentel@yahoo.com
  Subject: Re: An easy question about creating a primary key
  In-Reply-To: <20011203111257.H93680-100000@megazone23.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox