View Single Post

   
  #2 (permalink)  
Old 05-05-2008, 06:53 AM
chester c young
 
Posts: n/a
Default Re: numbering rows on import from file


--- Alexy Khrabrov <deliverable@gmail.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=Ahu06i...Dypao8Wcj9tAcJ

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote