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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://412089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found