Re: determine if a table exists

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: joseph(at)asti(dot)dost(dot)gov(dot)ph (Joseph Syjuco)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: determine if a table exists
Date: 2002-08-01 12:42:59
Message-ID: 200208011042.MAA22571@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> how do i determine if a table exists using select statement
> i want to find out if it exists if not ill create it if yes then ill do
> some editing with it
> TIA
>
do
SELECT relname FROM pg_class
WHERE relkind='r'
AND relname !~ '^pg_'
AND relname !~ '^pga_'
AND relname !~ '^pgadmin_';

You should also refer to Chapter 3. System Catalogs
in the Documentation.

Regards, Christoph

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-08-01 14:01:09 Re: Function problems, cache lookup failed
Previous Message Cédric Dufour 2002-08-01 11:35:13 Random resultset retrieving -> performance bottleneck