Re: ALTER TABLE modifications

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Rod Taylor <pg(at)rbt(dot)ca>, Hannu Krosing <hannu(at)tm(dot)ee>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: ALTER TABLE modifications
Date: 2003-11-14 15:59:31
Message-ID: 1068825571.1625.197.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

OK,

Here is another approach, that would retain column order. It will
require that the table be locked while this proceeds, but I think this
is a good idea anyway.

lock table
create newtable as select c1, c2, c3::newtype
modify pg_class to point to the new filename
modify existing pg_attribute for the column in question
recreate indexes that exist on the column
unlock table

Dave

On Fri, 2003-11-14 at 09:57, Peter Eisentraut wrote:
> Rod Taylor writes:
>
> > The method is rename old column, add new column, move data across, move
> > or reform dependencies, drop old column.
>
> I can do this by hand. If we have an explicit command to do it, then it
> needs to preserve the table schema. Else, this feature would be mostly
> useless and a certain source of complaints.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2003-11-14 16:06:59 Re: cvs head? initdb?
Previous Message Rod Taylor 2003-11-14 15:48:59 Re: ALTER TABLE modifications

Browse pgsql-patches by date

  From Date Subject
Next Message Greg Stark 2003-11-14 16:10:32 Re: heads up -- subtle change of behavior of new initdb
Previous Message Rod Taylor 2003-11-14 15:48:59 Re: ALTER TABLE modifications