Re: Add column

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Ioannis Theoharis <theohari(at)ics(dot)forth(dot)gr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Add column
Date: 2006-08-11 16:58:24
Message-ID: 20060811165824.GD950@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 11, 2006 at 07:35:29PM +0300, Ioannis Theoharis wrote:
>
>
> Hi, there is a feature that I would be glad if it was supported by
> PostgreSQL:
>
> I want to add a new column (attribute) to a pre-existed table, but instead
> of filling the values of this column with a default value (e.g. null) I
> would like to copy them from a file stored in my filesystem.
>
> I didn't find any example of mixing "copy" and "alter table ... add
> column" in the Documentation, however I send this mail to check it out.

That's because it doesn't make any sense. How does the alter table know
which row in the copy matches which row in the table? It's means you
need to do a join, at which point it would be easier to just copy into
a temp table and do an update to set the values.

alter table doesn't really have any magic in it w.r.t. setting the
default value.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

  • Add column at 2006-08-11 16:35:29 from Ioannis Theoharis

Browse pgsql-general by date

  From Date Subject
Next Message Roman Neuhauser 2006-08-11 17:33:37 Re: Tuning to speed select
Previous Message Martijn van Oosterhout 2006-08-11 16:51:24 Re: VACUUM VERBOSE output to STDERR