Re: [GENERAL] How to add columns to view with dependencies - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] How to add columns to view with dependencies
Date
Msg-id 24600.1492401151@sss.pgh.pa.us
Whole thread Raw
In response to [GENERAL] How to add columns to view with dependencies  (Guyren Howe <guyren@gmail.com>)
List pgsql-general
Guyren Howe <guyren@gmail.com> writes:
> Seems like a simple question, but I’ve never found a good answer to this and similar issues.
> I would think it was safe to let me add columns to a view on which other views depend, but Postgres won’t let me.

> I can imagine ways of sort-of dealing with this. I might maintain a SQL file with views to create in a suitable
order,Then I could drop all views, edit the definition of one, then run the file, but this is awfully tedious. 

> What is best practice in this situation?

Hm ... all currently-supported versions of Postgres will allow, eg,

regression=# create table t1 (f1 int, f2 int, f3 int);
CREATE TABLE
regression=# create view v1 as select f1 from t1;
CREATE VIEW
regression=# create or replace view v1 as select f1, f2 from t1;
CREATE VIEW
regression=# create view v2 as select * from v1;
CREATE VIEW
regression=# create or replace view v1 as select f1, f2, f3 from t1;
CREATE VIEW

So I think your options are (1) explain what you're really doing,
or (2) update.

            regards, tom lane


pgsql-general by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: [GENERAL] How to add columns to view with dependencies
Next
From: Karsten Hilbert
Date:
Subject: Re: [GENERAL] How to add columns to view with dependencies