pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: pgsql-sql@postgresql.org
To: yudie@axiontech.com
Subject: Re: Changing data type must recreate all views?
Date: Thu, 14 Aug 2003 17:18:03 +0200
Message-ID: <3F3BA82A.96D2F310@rodos.fzk.de> (raw)

>
> 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






view thread (3+ messages)  latest in thread

Message-ID: <3F3BA82A.96D2F310@rodos.fzk.de>
Permalink:  ../3F3BA82A.96D2F310@rodos.fzk.de/
Also on:    postgresql.org/message-id/3F3BA82A.96D2F310@rodos.fzk.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, yudie@axiontech.com
  Subject: Re: Changing data type must recreate all views?
  In-Reply-To: <3F3BA82A.96D2F310@rodos.fzk.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox