Re: Check If PostgreSQL Table Exists

Поиск
Список
Период
Сортировка
От Madison Kelly
Тема Re: Check If PostgreSQL Table Exists
Дата
Msg-id 43B81E5D.8040508@alteeve.com
обсуждение исходный текст
Ответ на Check If PostgreSQL Table Exists  (dhilchrist@gmail.com)
Список pgsql-general
dhilchrist@gmail.com wrote:
> Dear All,
>
> How To Check If PostgreSQL Table Exists in the Database Using Perl.
>
> Dhilchrist

Here is what I do...

$DBreq=$DB->prepare("SELECT COUNT(*) FROM pg_tables WHERE
tablename='foo'") || die $DBI::errstr;
$DBreq->execute();
my ($table_num)=$DBreq->fetchrow_array();
if ( $table_num < 1 )
{
    # Create the missing table
}
else
{
    # It exists!
}

Hope that helps!

Madison


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

Предыдущее
От: Scott Ribe
Дата:
Сообщение: Re: storing PDFs
Следующее
От: "Andrus Moor"
Дата:
Сообщение: pg_reload_conf() does not unset archive_command