Re: \copy and serial type
| От | Andrew McMillan |
|---|---|
| Тема | Re: \copy and serial type |
| Дата | |
| Msg-id | 1018864516.30516.328.camel@kant.mcmillan.net.nz обсуждение исходный текст |
| Ответ на | \copy and serial type (Masse Jacques <jacques.masse@bordeaux.cemagref.fr>) |
| Список | 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?
В списке pgsql-novice по дате отправления: