Re: [GENERAL] How to add columns to view with dependencies

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] How to add columns to view with dependencies
Дата
Msg-id 24600.1492401151@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [GENERAL] How to add columns to view with dependencies  (Guyren Howe <guyren@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: [GENERAL] How to add columns to view with dependencies
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: [GENERAL] How to add columns to view with dependencies