Re: Temporary views - Mailing list pgsql-general

From Tom Lane
Subject Re: Temporary views
Date
Msg-id 25125.1076631669@sss.pgh.pa.us
Whole thread Raw
In response to Re: Temporary views  (Christopher Browne <cbbrowne@acm.org>)
Responses Re: Temporary views  (Bruce Momjian <pgman@candle.pha.pa.us>)
List 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 by date:

Previous
From: "Jason Tesser"
Date:
Subject: Re: help with query speed
Next
From: Zak McGregor
Date:
Subject: Join 2 aggregate queries?