Re: Does this table exist? - Mailing list pgsql-general

From Warren Vanichuk
Subject Re: Does this table exist?
Date
Msg-id Pine.LNX.4.21.0011021304240.15920-100000@urd.street-light.com
Whole thread Raw
In response to Does this table exist?  (Alvaro Herrera <alvherre@protecne.cl>)
List pgsql-general
> Now, the question is: Is there a way to know if a given table exist?
> Besides doing a direct query to it, of course, as I think that would be
> too much of a dinamite-fishing way of doing it.

I believe you want the pg_tables table (view?)  A quick and dirty way would
be :

select tablename from pg_tables where tablename = 'tablecheck' and if you
get a row, the table exists.  Alternatively you could select tablename from
pg_tables where tableowner != 'postgres' and get a list of all tables in the
current database that don't belong to the postgresql system.

Though I'm also fairly new to PostgreSQL, so this could also be 'dynamite
fishing'  ;)

Sincerely, Warren
-----
Warren Vanichuk,  Systems Engineer,
Street Light Productions Ltd.


pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Does this table exist?
Next
From: Tom Lane
Date:
Subject: Re: CREATE FUNCTION problem