From: | Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz> |
---|---|
To: | Masse Jacques <jacques(dot)masse(at)bordeaux(dot)cemagref(dot)fr> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: \copy and serial type |
Date: | 2002-04-15 09:55:15 |
Message-ID: | 1018864516.30516.328.camel@kant.mcmillan.net.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Mon, 2002-04-15 at 21:42, Masse Jacques wrote:
> I use to enter data in my db with \copy large text files (exports from
> MS-Excel).
>
> Is there a mean to auto update the primary key (as serial) or do I have to
> calculate it each time with a function ?
Here's one way:
\copy table_without_serial from filename
create sequence myseq;
create table table_with_serial
as select nextval('myseq'), * from table_without_serial;
drop table_without_serial;
Regards,
Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Are you enrolled at http://schoolreunions.co.nz/ yet?
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua b. Jore | 2002-04-15 13:09:26 | Re: Referential Integrity |
Previous Message | Masse Jacques | 2002-04-15 09:42:06 | \copy and serial type |