Thanks Jonathan. I was thinking about doing something like this:
@tables = $dbh->tables();
if ((grep/$tableName/, @tables) <= 0) {
...
________________________________
From: Jonathan Leffler [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 27, 2006 5:17 PM
To: Loo, Peter # PHX
Cc: DBI users
Subject: Re: Checking if a table exist
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."
This E-mail message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply E-mail, and destroy all copies of
the original message.