Re: 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: Rodrigo De León <rdeleonp(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Fastest way to import only ONE column into a table? (COPY doesn't work)
Date: 2007-08-16 05:50:07
Message-ID: e373d31e0708152250u7274b30fl9bc2bcf856c0e62@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16/08/07, Rodrigo De León <rdeleonp(at)gmail(dot)com> wrote:
> On Aug 15, 11:46 pm, phoenix(dot)ki(dot)(dot)(dot)(at)gmail(dot)com ("Phoenix Kiula") wrote:
> > Appreciate any tips, because it would
> > be nasty to have to do this with millions of UPDATE statements!
>
> - Create an interim table
> - COPY the data into it
> - Do an UPDATE ... FROM ...

Thanks! I thought about it and then gave up because SQL trumped me up.
Could you please suggest what the query should look like?

Based on this:
http://www.postgresql.org/docs/8.1/static/sql-update.html

I tried this:

UPDATE
t1 SET title = title FROM t2
WHERE
t1.id = t2.id;

But I am miles from what it needs to be! The example in the docs does
not refer to a column in the other table, it just increments a value
in the same table based on the join ("UPDATE employees SET sales_count
= sales_count + 1 FROM accounts....").

TIA!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sabin Coanda 2007-08-16 06:17:37 Re: memory optimization
Previous Message David Fetter 2007-08-16 05:43:01 Re: language interface in postgresql