Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary table in pgAdmin

I am using pgAdmin for my Postgres 8.4 database and I was wondering where (any table/schema/etc. ?) may I find a list of currently used temporary tables? I assume there has to be a place where I can find it.

They are not present in a catalog object tables nor in views, any other suggestions?

like image 873
MPękalski Avatar asked Apr 04 '11 09:04

MPękalski


People also ask

How do you create a temporary table in Pgadmin?

Postgres creates a temporary schema for temporary tables named "pg_temp_#", you can see it with psql... create temp table mytemptable(name varchar); select c. relname from pg_namespace n join pg_class c on n. oid=c.

What is a temporary table in PostgreSQL?

A temporary table, as the name implies, is a short-lived table that exists for the duration of a database session. PostgreSQL automatically drops the temporary tables at the end of a session or a transaction.

Where is temp table stored in Postgres?

These tables reside inside tempdb , which is also a database system. ); Temporary tables are only visible within the session in which it was created; no other sessions will be able to view it.

How do I display a temporary table?

The name of a temporary table must start with a hash (#). Now, to see where this table exists; go to “Object Explorer -> Databases -> System Databases-> tempdb -> Temporary Tables”. You will see your temporary table name along with the identifier.


1 Answers

Postgres creates a temporary schema for temporary tables named "pg_temp_#", you can see it with psql...

create temp table mytemptable(name varchar);

select c.relname
from pg_namespace n
  join pg_class   c on n.oid=c.relnamespace
where n.nspname='pg_temp_1';

You can list your schemas executing "\dn" in psql.

Hope that helps.

like image 183
Cesar Avatar answered Sep 30 '22 00:09

Cesar