What is best way to query presence of a table

Поиск
Список
Период
Сортировка
Искать

What is best way to query presence of a table

От:
Medi Montaseri <medi.montaseri@intransa.com>
Дата:
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

Re: What is best way to query presence of a table

От:
Jochem van Dieten <jochemd@oli.tudelft.nl>
Дата:
 > Subject: What is best way to query presence of a table
 > From: Medi Montaseri 
 > Date: Thu, 02 Jan 2003 16:45:37 -0800
 > To: pgsql-general 
 >
 > What is the best way to query presence of a table

 > I'd like to solve this such that I'm protected from internal changes
 > within PG.

You might want to grab the INFORMATION_SCHEMA patch from the current 
source (src/backend/catalog) and apply that (after removing the check 
constraint on the domain, I think it is not implemented in 7.3). That 
would give you a method that should be safe for the future and portable 
to other databases.

Jochem

FAQ