Re: Changing data type must recreate all views? - Mailing list pgsql-sql

From Christoph Haller
Subject Re: Changing data type must recreate all views?
Date
Msg-id 3F3BA82A.96D2F310@rodos.fzk.de
Whole thread Raw
In response to Changing data type must recreate all views?  ("Yudie" <yudie@axiontech.com>)
List 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





pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: independent sequence for each month
Next
From: Jan Wieck
Date:
Subject: Re: [PERFORM] EXTERNAL storage and substring on long strings