Re: Changing data types

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: Changing data types
Дата
Msg-id 3BAF50AD.5A060EC5@tm.ee
обсуждение исходный текст
Ответ на Re: Changing data types  ("Gowey, Geoffrey" <ggowey@rxhope.com>)
Список 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: Changing data types
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: [SQL] outer joins strangeness