update from a csv file?

From: Kirk Wythers <wythe001(at)umn(dot)edu>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: update from a csv file?
Date: 2012-12-27 14:54:04
Message-ID: 549D5BE9-77D4-4F12-9F27-0ED0BEB39577@umn.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have been using COPY FROM to do a mass import of records from CSV files into a new database. I have discover however, a small number of records ( a few thousand) in one of the files that contain new data that needs to be added to the database, but on rows that have a primary key and have already been inserted (so I can't use COPY FROM because it violates the primary key).

If the structure of the table is

id data1 data2 data3

and the structure of the CSV file is

id data1 data2 data3

and I need to update all the rows in data3 where the id = id.

Is this a job for the UPDATE command? or is there a better way to pull data from a CSV file in order to do a mass update?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Gainty 2012-12-27 15:31:21 Re: New Zealand Postgis DBA job vacancy
Previous Message Amit Kapila 2012-12-27 09:48:22 Re: Cursor fetch Problem.