Using seq. objects with COPY FROM?

From: "Shivin M" <shivinm(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Using seq. objects with COPY FROM?
Date: 2006-11-20 14:00:01
Message-ID: 1773e4d70611200600k14a6ffe5nc58e60eccec88a75@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,
I was wondering whether you can make use of sequence objects along with COPY
FROM command?

This is my scenario:

I have table: name_list(id SERIAL PRIMARY KEY, name varchar(10))

So, there exists a sequence object: "name_list_id_seq" that starts from 1.

I have a CSV file <http://forums.devshed.com/#> that has names of people.
eg:

name

tom
mary
harry

Now, I want to read this file into the table 'name_table', and at the same
time, add sequence object's ("name_list_id_seq") next value to each row.
So, the contents of "name_table" now look like:

name_table

id name
--- -------
1 tom
2 mary
3 harry

Can anyone tell me how this can be done?
Thank you.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2006-11-20 14:15:35 Re: Using seq. objects with COPY FROM?
Previous Message A. Kretschmer 2006-11-20 06:06:53 Re: Aggregate Functions