Skip site navigation (1) Skip section navigation (2)

Re: numbering rows on import from file

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Alexy Khrabrov <deliverable(at)gmail(dot)com>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: numbering rows on import from file
Date: 2008-05-02 22:33:39
Message-ID: 369040.10710.qm@web54307.mail.re2.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
--- Alexy Khrabrov <deliverable(at)gmail(dot)com> wrote:

> Now I want to number the rows, adding an id column 
> as an autoincrement from a sequence.  How should I do the import now 
> for the sequence to work -- should I add the id column last, so it  
> will not be filled by copy and presumably autoincrement?

use a sequence
restart sequence to 1 before copy
have column id default to nextval('seq')

when doing copy don't have a column matching your id (duh)



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

In response to

pgsql-sql by date

Next:From: Scott MarloweDate: 2008-05-02 23:00:33
Subject: Re: numbering rows on import from file
Previous:From: Alexy KhrabrovDate: 2008-05-02 21:26:34
Subject: numbering rows on import from file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group