Re: Changing data type must recreate all views?

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: pgsql-sql(at)postgresql(dot)org, yudie(at)axiontech(dot)com
Subject: Re: Changing data type must recreate all views?
Date: 2003-08-14 15:18:03
Message-ID: 3F3BA82A.96D2F310@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> I need to change column data type from integer to float8
> That mean to droping table and recreate a new one and can lost the
original
> object id.
> Do i need to recreate all views and triggers that relate to that
table?
> if that so, is there anyway to do that without touching views and
triggers?
>
No, you don't have to drop and re-create.
How about
ALTER TABLE yourTable ADD COLUMN yourNewColumn double precision ;
UPDATE yourTable SET yourNewColumn = yourOldColumn ;
ALTER TABLE yourTable DROP COLUMN yourOldColumn ;
ALTER TABLE yourTable RENAME COLUMN yourNewColumn TO yourOldColumn ;

Views and triggers should work AFAIK, but if there are procedures
referencing the data type
of yourOldColumn, you have to re-create them changing the parameter type
from
integer to double precision.

Regards, Christoph

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-08-14 18:00:21 Re: [SQL] EXTERNAL storage and substring on long strings
Previous Message Jan Wieck 2003-08-14 15:02:53 Re: [SQL] EXTERNAL storage and substring on long strings