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

Re: Primary key on existing table?

From: Ries van Twisk <pg(at)rvt(dot)dds(dot)nl>
To: Carol Walter <walterc(at)indiana(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Primary key on existing table?
Date: 2009-08-25 22:11:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On Aug 25, 2009, at 3:25 PM, Carol Walter wrote:

> This may be a silly question but I don't see any place where the  
> documentation explicitly addresses whether or not you can designate  
> a particular column as a primary key after the table is created.  I  
> used the "create table as " syntax to create a table with the same  
> columns as an original table, but I want to rename id column, make  
> it a serial, and designate it as a primary key.  Is it possible to  
> do this?  I've tried a number of things to do this and none of them  
> have worked.

See this document:

for example: ALTER TABLE distributors ADD PRIMARY KEY (dist_id);

Also checkout pgAdmin III....


> Carol
> -- 
> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
> To make changes to your subscription:

			regards, Ries van Twisk

tags: Freelance TYPO3 Glassfish JasperReports JasperETL Flex Blaze-DS  
WebORB PostgreSQL DB-Architect
email: ries(at)vantwisk(dot)nl        web:     
skype: callto://r.vantwisk
Phone: +1-810-476-4196    Cell: +593 9901 7694                   SIP:  

In response to

pgsql-admin by date

Next:From: Scott MarloweDate: 2009-08-25 22:25:19
Subject: Re: Primary key on existing table?
Previous:From: Kevin GrittnerDate: 2009-08-25 21:55:57
Subject: Re: Primary key on existing table?

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