Re: Create Primary Key? - Mailing list pgsql-sql

From Jie Liang
Subject Re: Create Primary Key?
Date
Msg-id 39AC687D.D38ACA3D@ipinc.com
Whole thread Raw
In response to Create Primary Key?  (Webb Sprague <wsprague100@yahoo.com>)
List pgsql-sql
Hi,

It suppose to use ALTER TABLE tablename ADD constraint xxx primary
key(columnname),
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!
> http://mail.yahoo.com/

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com





pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: Optimizing huge inserts/copy's
Next
From: Stephan Szabo
Date:
Subject: Re: Optimizing huge inserts/copy's