What is best way to query presence of a table

From: Medi Montaseri <medi(dot)montaseri(at)intransa(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: What is best way to query presence of a table
Date: 2003-01-03 00:45:37
Message-ID: 3E14DD31.8060706@intransa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What is the best way to query presence of a table

select relname from pg_class where relname = 'SomeTable';

or

select * from SomeTable -- I know this one succss but I don't have to
wory
about pg_* changing under me....

or

select exists('SomeTable');

Where exists() is a pg built in function -- I am wishing here for a feature

I'd like to solve this such that I'm protected from internal changes
within PG.
Obviously the suggested method above similar to version() can abstract that.

Also, when I create my table, can I say create or replace (for base
tables) ?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-01-03 00:47:03 Re: pg_restore woes..
Previous Message Alvaro Herrera 2003-01-03 00:27:50 Re: pg_restore woes..