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

Re: Create Primary Key?

From: Jie Liang <jliang(at)ipinc(dot)com>
To: Webb Sprague <wsprague100(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Create Primary Key?
Date: 2000-08-30 01:50:53
Message-ID: (view raw or whole thread)
Lists: pgsql-sql

It suppose to use ALTER TABLE tablename ADD constraint xxx primary
unforturatly, Pg7.0 still haven't implemented it yet, so except foreign
key ,other constarints,
you have to choose:
1. rename your old table, recreate an new one with primary key, then use

insert into newtable select * from oldtable.
2. use pg_dump -t tablename -f scriptfile dbname
in shell , edit that scriptfile, add primary key there,
drop your table, then reload it again:
psql dbname<scriptfile

Webb Sprague wrote:

> Apropos of my last question:
> Is there syntax to create a primary key after the
> table has been defined and populated?  I think I could
> speed things up quite a bit by not having any indexes
> at all when I do my mass copies.
> Thanks, and my apologies if that is a totally stupid
> question.
> W
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!


Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121


In response to

pgsql-sql by date

Next:From: Stephan SzaboDate: 2000-08-30 01:55:42
Subject: Re: Optimizing huge inserts/copy's
Previous:From: Jie LiangDate: 2000-08-30 01:39:50
Subject: Re: Optimizing huge inserts/copy's

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