Re: Mass Import/Generate PKs

From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: Hunter Hillegas <lists(at)lastonepicked(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Mass Import/Generate PKs
Date: 2004-11-06 22:12:16
Message-ID: 1099779136.5308.2.camel@taz.oficina
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've tested it, and the SERIAL type populates the column when you add it
;)

On Sat, 2004-11-06 at 18:56, Ed L. wrote:

> On Saturday November 6 2004 2:13, Franco Bruno Borghesi wrote:
> > the simplest way to do it seems to be adding a SERIAL column to your
> > table, and then adding a primary key constraint:
> >
> > 1)insert data into table
> > 2)ALTER TABLE <table> ADD id SERIAL;
> > 3)ALTER TABLE <table> ADD CONSTRAINT <table>_pk PRIMARY KEY (id);
>
> You may also need to populate the id column with unique values in between
> these two steps with something like "
>
> update table set id = nextval('table_id_seq'::text) where id isnull"
>
> I don't think SERIAL does that for you.
>
> Ed
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Stevenson 2004-11-06 22:17:19 Re: Trying to get postgres to use an index
Previous Message mike 2004-11-06 22:01:25 Re: Trying to get postgres to use an index