Re: Temporary views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Temporary views
Date: 2004-02-13 00:21:09
Message-ID: 25125.1076631669@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christopher Browne <cbbrowne(at)acm(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Tesser 2004-02-13 00:22:24 Re: help with query speed
Previous Message Zak McGregor 2004-02-13 00:13:11 Join 2 aggregate queries?