Re: Checking if a table exist
- From: jonathan.leffler@xxxxxxxxx (Jonathan Leffler)
- Date: Thu, 27 Apr 2006 17:17:26 -0700
On 4/27/06, Loo, Peter # PHX <Peter.Loo@xxxxxxxxxxxxxxxxxxxxxxxx> 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 <jonathan.leffler@xxxxxxxxx> #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."
- Follow-Ups:
- Re: Checking if a table exist
- From: Ron Savage
- Re: Checking if a table exist
- References:
- Checking if a table exist
- From: Peter # PHX Loo
- Checking if a table exist
- Prev by Date: dbi.perl.org isn't working all that great
- Next by Date: Re: Checking if a table exist
- Previous by thread: Checking if a table exist
- Next by thread: Re: Checking if a table exist
- Index(es):