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?