Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 studying the Monastery: (7)
As of 2015-07-06 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls