Re: Adding PK to Existing Table

From: Raghavendra <raghavendra(dot)rao(at)enterprisedb(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding PK to Existing Table
Date: 2011-04-01 15:43:52
Message-ID: AANLkTi=GfGQpA3bp=T0jehuSC7TEp5pVrOtUK+QxY1jN@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try out this...

alter table <table name> add primary key(column name);

Best Regards,
Raghavendra
EnterpriseDB Corporation

On Fri, Apr 1, 2011 at 9:09 PM, Rich Shepard <rshepard(at)appl-ecosys(dot)com>wrote:

> In -9.0.3 I used ALTER TABLE to replace a varchar() column with a bigint
> column so it can be assigned as the table's primary key. From the 9.0.3
> manual I tried various flavors of ALTER TABLE <tablename> ADD CONSTRAINT
> but
> cannot find the proper syntax to create the PK. Do I need to first make the
> column UNIQUE, then add a NOT NULL constraint?
>
> Rich
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raghavendra 2011-04-01 16:01:13 Re: How to get index columns/dir/ord informations?
Previous Message Rich Shepard 2011-04-01 15:39:09 Adding PK to Existing Table