Re: Temporary views

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Temporary views
Date: 2004-02-13 02:30:54
Message-ID: 200402130230.i1D2Usv12366@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> 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.

TODO has:

* Have views on temporary tables exist in the temporary
namespace

One thing we don't have is the ability to create a temp view on a real
table, which we don't support right now.

I have added this to TODO:

* Allow temporary views on non-temporary tables

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message CSN 2004-02-13 08:18:14 update set x=(subquery on same table)
Previous Message Cott Lang 2004-02-13 02:06:42 Re: pg_dump/pg_restore problems with 7.4.1