Skip site navigation (1) Skip section navigation (2)

Re: BUG #3597: CREATE OR REPLACE VIEW

From: Reece Hart <reece(at)harts(dot)net>
To: "Luiz K(dot) Matsumura" <luiz(at)planit(dot)com(dot)br>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3597: CREATE OR REPLACE VIEW
Date: 2007-09-04 17:33:27
Message-ID: 1188927207.5144.26.camel@snafu.site (view raw or flat)
Thread:
Lists: pgsql-bugs
On Tue, 2007-09-04 at 07:42 +0000, Luiz K. Matsumura wrote:

> When we do a command Create or Replace View that change columns of
> previous view we got a error.


Right. Many folks consider views to be a sort of API to the database.
Using views to provide an API substantially insulates client code from
implementation changes because the logic "behind" a view can change
without changing the interface. So, although the prohibition against
changing the column specification is occasionally irksome, I have grown
to appreciate the protection from wanton changes to the API that this
prohibition provides.

Here are two tricks that may help you (and which you may already know):

1) Views can be renamed. When you do this, nearly all intra-cluster
references to it are updated. So, if your view is /solely/ for use
within the database, this allows you to deprecate a view.

2) Views can depend on views. So, consider your view1 as version1, then
create view2 which depends on view1 and merely recasts the type1 column
as character(3). New code can use view2 and old code can be migrated to
view2 as needed.

-Reece

-- 
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

In response to

pgsql-bugs by date

Next:From: Luiz K. MatsumuraDate: 2007-09-04 18:09:16
Subject: Re: BUG #3597: CREATE OR REPLACE VIEW
Previous:From: Jukka HolappaDate: 2007-09-04 17:02:30
Subject: Re: BUG #3595: Segmentation fault with a simple select query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group