pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Create Primary Key?
5+ messages / 4 participants
[nested] [flat]

* Create Primary Key?
@ 2000-08-30 00:37 Webb Sprague <wsprague100@yahoo.com>
  2000-08-30 01:10 ` Re: Create Primary Key? Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2000-08-30 01:50 ` Re: Create Primary Key? Jie Liang <jliang@ipinc.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Webb Sprague @ 2000-08-30 00:37 UTC (permalink / raw)
  To: pgsql-sql

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/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Create Primary Key?
  2000-08-30 00:37 Create Primary Key? Webb Sprague <wsprague100@yahoo.com>
@ 2000-08-30 01:10 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2000-08-30 11:42   ` Re: Create Primary Key? D'Arcy J.M. Cain <darcy@druid.net>
  1 sibling, 1 reply; 5+ messages in thread

From: Stephan Szabo @ 2000-08-30 01:10 UTC (permalink / raw)
  To: Webb Sprague <wsprague100@yahoo.com>; +Cc: pgsql-sql


We don't currently support the SQL syntax for adding
a PK to a table.  However, if you have the columns
as NOT NULL already, adding a unique index to the
columns in question has the same general effect.

Stephan Szabo
sszabo@bigpanda.com

On Tue, 29 Aug 2000, 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.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Create Primary Key?
  2000-08-30 00:37 Create Primary Key? Webb Sprague <wsprague100@yahoo.com>
  2000-08-30 01:10 ` Re: Create Primary Key? Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2000-08-30 11:42   ` D'Arcy J.M. Cain <darcy@druid.net>
  2000-08-30 14:52     ` Re: Create Primary Key? Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 5+ messages in thread

From: darcy@druid.net @ 2000-08-30 11:42 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: Webb Sprague <wsprague100@yahoo.com>; pgsql-sql

Thus spake Stephan Szabo
> We don't currently support the SQL syntax for adding
> a PK to a table.  However, if you have the columns
> as NOT NULL already, adding a unique index to the
> columns in question has the same general effect.

Except for interfaces such as PyGreSQL that recognize the primary key
and use it.

> > 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.

Why not just use the copy function?  That's what it's for.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Create Primary Key?
  2000-08-30 00:37 Create Primary Key? Webb Sprague <wsprague100@yahoo.com>
  2000-08-30 01:10 ` Re: Create Primary Key? Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2000-08-30 11:42   ` Re: Create Primary Key? D'Arcy J.M. Cain <darcy@druid.net>
@ 2000-08-30 14:52     ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Stephan Szabo @ 2000-08-30 14:52 UTC (permalink / raw)
  To: D'Arcy J.M. Cain <darcy@druid.net>; +Cc: Webb Sprague <wsprague100@yahoo.com>; pgsql-sql


On Wed, 30 Aug 2000, D'Arcy J.M. Cain wrote:

> Thus spake Stephan Szabo
> > We don't currently support the SQL syntax for adding
> > a PK to a table.  However, if you have the columns
> > as NOT NULL already, adding a unique index to the
> > columns in question has the same general effect.
> 
> Except for interfaces such as PyGreSQL that recognize the primary key
> and use it.

True.  You'd have to see what it was doing to determine the primary key
and try to do the same things.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Create Primary Key?
  2000-08-30 00:37 Create Primary Key? Webb Sprague <wsprague100@yahoo.com>
@ 2000-08-30 01:50 ` Jie Liang <jliang@ipinc.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Jie Liang @ 2000-08-30 01:50 UTC (permalink / raw)
  To: Webb Sprague <wsprague100@yahoo.com>; +Cc: 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






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2000-08-30 14:52 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-30 00:37 Create Primary Key? Webb Sprague <wsprague100@yahoo.com>
2000-08-30 01:10 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2000-08-30 11:42   ` D'Arcy J.M. Cain <darcy@druid.net>
2000-08-30 14:52     ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2000-08-30 01:50 ` Jie Liang <jliang@ipinc.com>

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