Fastest way to import only ONE column into a table? (COPY doesn't work)

From: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Fastest way to import only ONE column into a table? (COPY doesn't work)
Date: 2007-08-16 04:46:22
Message-ID: e373d31e0708152146n6da0e4ddwbaad8e0d3c8cd534@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What is the fastest way to import the values of *only one* column into
an already existing table? Say the table looks like this:

id (primary key)
description
created_on

I want to import only a new column so the table looks like this:

id (primary key)
title
description
created_on

So I have a large-ish text file with the following format:

id1||title1
id2||title2
id3||title3
id4||title4
id5||title5
id6||title6

I try to import it in with

COPY table1 (id, title) from "/usr/tmp/titles.txt"

But this doesn't seem to be working, because COPY doesn't know how to
UPDATE values, it just inserts. Appreciate any tips, because it would
be nasty to have to do this with millions of UPDATE statements!

TIA

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Decibel! 2007-08-16 04:47:07 Re: Interpreting statistics collector output
Previous Message Decibel! 2007-08-16 04:45:01 Re: Deadlocks caused by a foreign key constraint