Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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.

Replies are listed 'Best First'.
Re^2: DBI: checking if a table exists in a cross-DB manner?
by Anonymous Monk on Aug 25, 2016 at 14:06 UTC
    Thank u, is very simple and works!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412089]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2016-12-03 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.