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

copy from file and overwrite existing entries?

From: Mattes Sarcander <mtsrc(at)systemausfall(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: copy from file and overwrite existing entries?
Date: 2005-06-27 14:33:59
Message-ID: 20050627163359.5e7b3639@carnivore.local (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,
I am really new to database administration, so forgive me if I overlook
something obvious ;>

I want to import data from a csv file into an existing, non-empty table.
My problem is the fact that I get an "ERROR:  duplicate key violates
unique constraint", because, as psql correctly grumbles, some entries
are already inside the tables. I would like to overwrite these existing
entries, as the data from the csv files is newer.
I have seen the UPDATE command, but I don't know how to combine that
with import from a file.

How can I accomplish that import? And what is the technically correct
description of my problem, so I can use a search engine next time? 

Thanks in advance,
Mattes

Responses

pgsql-novice by date

Next:From: Andreas KretschmerDate: 2005-06-27 14:52:11
Subject: Re: [despammed] copy from file and overwrite existing entries?
Previous:From: MinalDate: 2005-06-27 06:34:28
Subject: Problem with startup

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