On 4/27/06, Loo, Peter # PHX <[EMAIL PROTECTED]> wrote:

> Does anyone know of a good way to check if a table exist disregarding
> whether the table has data or not?
>

Simplest is:

my $sth = $dbh->prepare("SELECT * FROM $tablename");
if ($sth) { ...table exists...probably; you might need to do $sth->execute
to be sure as different DBMS differ... }
else      { ...table probably doesn't exist, or it exists but you don't have
select permission on it... }

Or you can play with table_info, etc.

--
Jonathan Leffler <[EMAIL PROTECTED]>  #include <disclaimer.h>
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."

Reply via email to