Re: temp table existence

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Marcin Krawczyk" <jankes(dot)mk(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: temp table existence
Date: 2007-12-29 21:23:51
Message-ID: 162867790712291323m2d7212e9i6e85d7b128e9dc1c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

my solution isn't 100% perfect too. Better is test visibility:

SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i'
THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as
"Type",
r.rolname as "Owner"
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_roles r ON r.oid = c.relowner
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
AND n.nspname <> 'pg_catalog' -- replace LIKE 'pg_temp%';
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;

for existence test this query can be simplified
Regards
Pavel Stehule

On 29/12/2007, Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com> wrote:
> I just realized something... my bad. It will work since TRUNCATE removes
> only table from current session.
>
> Thank you again.
> Regards
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2007-12-29 22:25:23 Re: temp table existence
Previous Message Marcin Krawczyk 2007-12-29 21:16:23 Re: temp table existence