Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: DBI: checking if a table exists in a cross-DB manner?

by htoug (Deacon)
on Dec 03, 2004 at 11:29 UTC ( #412089=note: print w/ replies, xml ) Need Help??


in reply to DBI: checking if a table exists in a cross-DB manner?

You should use the $dbh->table_info(...) method.

It will return a statement handle, that iterates the table(s) you define, thus alloowing easy check whether a table exists.

Your call would be something like

$sth=$dbh->table_info("", $schema, $table_name, "TABLE"); if ($sth->fetch) { # table exists } else { # doesn't }
This will work on all DBD's (as soon as the authors have implemented the table_info method - most have). If yours doesn't work, then please contact your DBD-author and help him get it done.


Comment on Re: DBI: checking if a table exists in a cross-DB manner?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-12-25 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls