Re: How to check if a table exists

Поиск
Список
Период
Сортировка
От Tim Barnard
Тема Re: How to check if a table exists
Дата
Msg-id 00d801c0a7f0$032945c0$a519af3f@hartcomm.com
обсуждение исходный текст
Ответ на How to check if a table exists  ("Jeff" <jklcom@mindspring.com>)
Список pgsql-general
Test result of PQexec() using PQresultstatus(). On success you'll get a
PGRES_TUPLES_OK result.
Your subsequent call to PQfname() will contain the word "count" and a
similar call to PQgetvalue() will contain count's value, as a string of
course. If count = 0, table missing. If count = 1, table is present.

Checkout the source for psql to see how to use aforementioned functions.

Have fun ;-)

Tim

----- Original Message -----
From: "Jeff Lu" <jklcom@mindspring.com>
To: "Tim Barnard" <tbarnard@povn.com>
Sent: Thursday, March 08, 2001 8:25 PM
Subject: RE: [GENERAL] How to check if a table exists


> Thanks Tim,
>
> What's the syntax for testing count?  Is count a variable?
>
> Thanks
> -Jeff
>
> -----Original Message-----
> From: Tim Barnard [mailto:tbarnard@povn.com]
> Sent: Thursday, March 08, 2001 11:16 AM
> To: Jeff
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] How to check if a table exists
>
>
> I do it this way using libpq: select count(*) from pg_class where
> relname='table name goes here'
> and test for a count > 1.
>
> Tim
>
> ----- Original Message -----
> From: "Jeff" <jklcom@mindspring.com>
> To: <pgsql-general@postgresql.org>
> Sent: Wednesday, March 07, 2001 8:48 PM
> Subject: [GENERAL] How to check if a table exists
>
>
> > Also how to programmatically check if a table exists in the database?
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> >
>
>


В списке pgsql-general по дате отправления:

Предыдущее
От: Barry Lind
Дата:
Сообщение: Re: length of insert stmt?
Следующее
От: "Brian C. Doyle"
Дата:
Сообщение: Win32 Postgresql