Re: Checking if a table exist
- From: ron@xxxxxxxxxxxxx (Ron Savage)
- Date: Fri, 28 Apr 2006 10:27:58 +1000
On Thu, 27 Apr 2006 17:17:26 -0700, Jonathan Leffler wrote:
Hi Jonathan
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... }
I'd suggest "Select * from $tablename where 1=2" so that if you do need to call
execute, you return nothing, if at all possible.
--
Ron Savage
ron@xxxxxxxxxxxxx
http://savage.net.au/index.html
.
- References:
- Re: Checking if a table exist
- From: Jonathan Leffler
- Re: Checking if a table exist
- Prev by Date: Re: Checking if a table exist
- Next by Date: RE: Checking if a table exist
- Previous by thread: Re: Checking if a table exist
- Next by thread: RE: Checking if a table exist
- Index(es):