[SGVLUG] Meta-querying (perhaps OT...)

Emerson, Tom (*IC) Tom.Emerson at wbconsultant.com
Mon Jul 7 13:51:42 PDT 2008


If I'm reading this correctly (though mostly I'm inferring this from the
function name), it appears this lists all of the columns [fields] of the
dataset [table] "people" -- that isn't what I want, I'm after all the
tables that contain the column "first_name".  In addition, (and this is
the harder part), I'd like to know where the DBA chose to name the field
"FirstName", "fName", or simply "name"... [and, to a lesser extent, are
these all of compatible forms, i.e., "varchar(n)" where "n" is
consistent among instances...]
 
-----Original Message-----Of Matt Campbell 

You can do this easily in mySQL if you have privs to open the database.
I don't know how to do it in DB2 though.

 

 

P.S.  The following is off the top of my head from some time ago so it
probably needs double checking.

The basic function should work with any DB Perl has drivers for.

 

 [...] listTableColums($db, 'people');

 

sub listTableColumns {

                my ($db, $table) = @_;

 

 [...]

                my $sth = $dbh->column_info(undef, undef, $table,
undef);




 

From: sgvlug-bounces at sgvlug.net [mailto:sgvlug-bounces at sgvlug.net] On
Behalf Of Emerson, Tom (*IC)
Sent: Monday, July 07, 2008 12:04 PM
To: SGVLUG Discussion List.
Subject: [SGVLUG] Meta-querying (perhaps OT...)

 

This is more for the database guru's out there -- specifically, for DB2:
is there a way to perform a "meta" query on a database?  In particular,
I'd like to find out what tables contain a particular field (by name, or
possibly by structure as it's possible that the "name" of the field
isn't consistent across datasets)

[...]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.sgvlug.net/pipermail/sgvlug/attachments/20080707/f2d3db37/attachment.html


More information about the SGVLUG mailing list