VIEW AS SELECT -vs- INSERT INTO table query

Поиск
Список
Период
Сортировка
От Frank Bax
Тема VIEW AS SELECT -vs- INSERT INTO table query
Дата
Msg-id 5.2.1.1.0.20051111094611.02dfcec0@pop6.sympatico.ca
обсуждение исходный текст
Ответы Re: VIEW AS SELECT -vs- INSERT INTO table query  ("Greg Sabino Mullane" <greg@turnstep.com>)
Список pgsql-novice
I have a table of items with about 50 columns, one of which is 'owner'.  I
would like to run several queries where the items for several 'owners' are
to be treated as one owner.  I have considered several options, but they
all have problems:

1) Create a view.
    CREATE VIEW itemcombo AS SELECT 'Combined', [columns] FROM items WHERE
owner IN (...);
where [columns] is everything *except* owner?  Is there a syntax for this
command that would avoid typing all 50 columns?  If I add a new column to
underlying table, then view needs to be replaced?  Is it possible to create
this view in such a way that it could handle "normal" queries of the
underlying table as well (where owner <> 'Combined')?

2) Create a new owner 'Combined' and use "INSERT INTO table query" to
populate items under this owner.
    INSERT INTO items SELECT 'Combined', [columns] FROM items WHERE owner IN
(...);
Again, we have a problem with all those columns.  Also, this command needs
to be rerun whenever underlying table is modified (which, luckily, is not
often).

3) Push the problem to user code.  Every query contains "WHERE owner IN
(...)" instead of "WHERE owner='Combined'".

Are there alternate solutions that I've missed?


В списке pgsql-novice по дате отправления:

Предыдущее
От: Frank Hu
Дата:
Сообщение: psql output Horizontal scrollable ?
Следующее
От: Sean Davis
Дата:
Сообщение: Re: psql output Horizontal scrollable ?