From: | Hannu Krosing <hannu(at)tm(dot)ee> |
---|---|
To: | "Gowey, Geoffrey" <ggowey(at)rxhope(dot)com> |
Cc: | "'Alex Pilosov'" <alex(at)pilosoft(dot)com>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Changing data types |
Date: | 2001-09-24 15:26:37 |
Message-ID: | 3BAF50AD.5A060EC5@tm.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Gowey, Geoffrey" wrote:
>
> One thought did just occur to me. It is at least theoretically possible to
> simplisticly migrate on column type to another by reading in the data and
> oid of the row into a struct, drop the column, create a new column with the
> correct data type, and populate. This is ugly, but it is better than saying
> "no, you can't".
The DROP COLUMN part is the one that is what's really hard.
It is not currently supported in postgreSQL
Supporting it comes up now and then, but as the solution (changing
system tables
and then rewriting the whole table) is considered ugly in current
implementation
it has always windled down to not doing it.
The way to manually change column type is something like:
alter table mytable add column newcolumn int;
update table set newcolumn = oldcolumn;
alter table rename oldcolumn to __del__001;
alter table rename newcolumn to oldcolumn;
but you can't DROP COLUMN without recreating the TABLE
------------
Hannu
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2001-09-24 16:07:31 | Re: [SQL] outer joins strangeness |
Previous Message | Josh Berkus | 2001-09-24 15:11:59 | Re: Bug?: Update on ancestor for a row of a child |