Re: Altering a column type w/o dropping views

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Altering a column type w/o dropping views
Date: 2008-07-07 12:50:50
Message-ID: 20080707125049.GA45839@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 07, 2008 at 05:53:58PM +0800, Ow Mun Heng wrote:
> I'm going to alter a bunch a tables columns's data type and I'm being
> forced to drop a view which depends on the the colum.

Why is that a problem? If you keep your object definitions in files
(e.g., in a directory structure that's under revision control) then
you can write a deployment script like the following (to be executed
via psql):

BEGIN;
DROP VIEW view_name;
ALTER TABLE table_name ALTER column_name TYPE type_name;
\i views/view_name.sql
COMMIT;

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2008-07-07 13:10:19 Re: Postgres benchmark?
Previous Message André Volpato 2008-07-07 12:43:13 Re: creating "a perfect sequence" column