Home: Perl Programming Help: DBI:
How to get all tables name from database....



dashang.trivedi
Novice

May 30, 2011, 6:33 AM


Views: 15090
How to get all tables name from database....

Hello Every one......

my objective is to fetch all the TABLE NAME from database..i want to fetch the META-DATA of database....
which is the easiest way to do this???
Is their any module is available for that...???


FishMonger
Veteran / Moderator

May 30, 2011, 9:06 AM


Views: 15084
Re: [dashang.trivedi] How to get all tables name from database....

http://search.cpan.org/~timb/DBI-1.616/DBI.pm#tables


miller
User

May 31, 2011, 2:20 PM


Views: 15045
Re: [dashang.trivedi] How to get all tables name from database....

Just use DBI like FishMonger suggested to connect to the database, and to the sql query "SHOW TABLES".

- Miller


dashang.trivedi
Novice

May 31, 2011, 10:46 PM


Views: 15036
Re: [FishMonger] How to get all tables name from database....

hi sir thank you for replying...

I check DBI link already....and i found this way.....
i want for oracle and Postgres database

Code
my @tables = $dbh->tables ( ); 
foreach $table (@tables ){
print "Table Name $table\n";
#print TXT "$table \n";
}



but this is very time consuming process ...u know any other way....????
and one more thing
In Postgres SQL i can search a pattern $dbh->tables ('','','tbl%','' );

In Oracle how this thing is done ???


(This post was edited by dashang.trivedi on May 31, 2011, 10:47 PM)


dashang.trivedi
Novice

May 31, 2011, 10:50 PM


Views: 15034
Re: [miller] How to get all tables name from database....

hi miller thank you for reply me second time and help me.....

Miller SHOW TABLES is only work in MYSQL ...u know for POSTGRES SQL and ORACLE....?????