Gaurav
Gaurav

Reputation: 33

View using TEMP table in postgresql also not visible outside session

I am creating temp table in postgresql, and there are views which are using temp table , strangely those are also not visible outside of session , is there any way to view to be visible to outside session and also is there any way temp table is also visible to outside of session

Upvotes: 0

Views: 170

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247865

A view on a temporary table is automatically a temporary view:

CREATE TEMP TABLE tab (x integer);

CREATE VIEW v AS SELECT * FROM tab;
NOTICE:  view "v" will be a temporary view

Temporary views behave like temporary tables: they will be gone as soon as the session ends, and they are only accessible from the session that created them.

You will never be able to give another session access to data in a temporary table. Whatever the problem is you are trying to solve, this cannot be the solution.

Upvotes: 1

Related Questions