Dropping a temporary view?

From: Celia McInnis <celia(dot)mcinnis(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Dropping a temporary view?
Date: 2024-03-20 14:58:00
Message-ID: CAGD6t7JniiFU5_tu=1Dpa1-E_HjVdWyT8T7RaU6uTZ-7WF9TiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I am using postresql 16, am trying to use temporary views in a piece of
software that I am writing, and would like it to be able to drop and
recreate temporary views. It seems from the documentation that I can only
use "CREATE OR REPLACE TEMPORARY VIEW" if the replacement view has the same
columns, so Is there a correct way to drop a temporary view?

I can create a temporary view, but get a syntax error when I do what I
thought would drop it. Here is a simple example of what doesn't work:

tt=# create temporary view tempview as select now() as junk;
CREATE VIEW
tt=# select * from tempview;
junk
-------------------------------
2024-03-20 14:21:27.441168+00
(1 row)

tt=# drop temporary view tempview;
ERROR: syntax error at or near "temporary"
LINE 1: drop temporary view tempview;
^

Also, when I then tried (I formerly had a non-temporary view called
tempview)

DROP VIEW tempview;
DROP VIEW

postgresql did that successfully, but when I then did

select * from tempview:

postgresql hung for a long time (more than 7 minutes) before returning the
contents of some previous view tempview (a previous (temporary, I guess)
view by that name that was created by my software when I was not creating a
temporary view?). I really wasn't expecting this, so if someone can
explain, that would be great.

Thanks,
Celia McInnis

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2024-03-20 15:12:29 Re: Dropping a temporary view?
Previous Message Erik Wienhold 2024-03-20 14:43:31 Re: SSL error on install of PEM during Posgres install