Re: ALTER TABLE

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Hannu Krosing <hannu(at)tm(dot)ee>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE
Date: 2003-08-29 12:56:19
Message-ID: 1062161778.80333.225.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2003-08-29 at 04:22, Hannu Krosing wrote:
> Rod Taylor kirjutas R, 29.08.2003 kell 03:31:
> > I've been fiddling away on ALTER TABLE and have a few questions about a
> > possible datatype change. Just alter portions.
> >
> > I presume I'll need to do a table rewrite. What is the best way to
> > change a single datum? heap_modify() takes a single relation type where
> > I will need to deal with different types. Simply build a new tuple with
> > old datums (easy enough)? Do we care about OIDs being renumbered?
>
> AFAIK alter table change column should do the equivalent of
>
> alter table x add column temp_name newdatatype;
> update table x set temp_name=convert(name);
> alter table x drop colum name;
> alter table x rename column temp_name to name;

I presume we want the attnum needs to be preserved to preserve the
constraints that are pointing at the column. Yes, constraints may need
a cast injects (view too), but if we're not going to do that there is
little advantage over doing the job by hand. as the above 4 step
process.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-08-29 13:20:48 Re: Obscure: correctness of lock manager???
Previous Message Fabian Kreitner 2003-08-29 12:52:10 Force table to be permanently in cache?