Re: Temporary views

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Temporary views
Дата
Msg-id 25125.1076631669@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Temporary views  (Christopher Browne <cbbrowne@acm.org>)
Ответы Re: Temporary views  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-general
Christopher Browne <cbbrowne@acm.org> writes:
>> Whether it's worth the trouble is another question.  What's the
>> use-case?

> It's where you create a temporary table to store some results, but
> then want to create a view on top of that, because that makes some
> funky self-join more convenient.

> I found myself wanting this very thing last night when generating a
> report.  (Believe it or not!)

Hmm.  Interestingly enough, you can do that right now (in 7.3 or later):

regression=# create temp table foo as select * from int8_tbl;
SELECT
regression=# create view v as select * from foo;
CREATE VIEW
regression=# \c -
You are now connected to database "regression".
regression=# \dv v
No matching relations found.

The view goes away at backend exit because it has a dependency on foo.

Whether this is really desirable or not, I'm not sure.  It would
probably be better if you'd had to say "create temp table v", just
to avoid surprises.

            regards, tom lane

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

Предыдущее
От: "Jason Tesser"
Дата:
Сообщение: Re: help with query speed
Следующее
От: Zak McGregor
Дата:
Сообщение: Join 2 aggregate queries?