Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get schemas from Perl's DBI?

Tags:

schema

perl

dbi

I am using Perl DBI. I know that $dbase->tables() will return all the tables in the corresponding database. Likewise, I want to know the schemas available in the database. Is there any function available for that?

like image 425
karthi_ms Avatar asked May 25 '10 10:05

karthi_ms


1 Answers

What you're looking for is: DBI->table_info()

Call it like this:

my $sth = $dbh->table_info('', '%', '');
my $schemas = $dbh->selectcol_arrayref($sth, {Columns => [2]});
print "Schemas: ", join ', ', @$schemas;
like image 158
Uncle Arnie Avatar answered Sep 28 '22 18:09

Uncle Arnie