#!/usr/bin/perl -w

use DBI;

print "$DBI::VERSION\n";

my $dbh = DBI->connect() or die "unable to connect: ", $DBI::errstr;

my @tables = $dbh->tables() or die "Tables failed: ", $DBI::errstr;

foreach my $table (@tables) {
                print "table: $table\n";
}

$dbh->disconnect;

exit;

Results:
T:\projects\DBD-ADO\ex>perl -w tb.pl
1.28
table: MSysAccessObjects
table: MSysACEs
table: MSysObjects
table: MSysQueries
table: MSysRelationships
table: demo
table: demo3
table: tst

Here is what I get using DBD::ADO with an Access database:

T:\projects\DBD-ADO>dbish
DBI::Shell 11.9 using DBI 1.28
....
Connecting to 'dbi:ADO:File Name=access.udl' as ''...
/option prompt=ado--  (was dbi:ADO:File Name=access.udl)
Loaded plugins DBI::Shell::SQLMinus
@ado--> /tab
TABLE_CAT,TABLE_SCHEM,TABLE_NAME,TABLE_TYPE,REMARKS
undef,undef,'demo','TABLE',undef
undef,undef,'demo3','TABLE',undef
undef,undef,'MSysAccessObjects','ACCESS TABLE',undef
undef,undef,'MSysACEs','SYSTEM TABLE',undef
undef,undef,'MSysObjects','SYSTEM TABLE',undef
undef,undef,'MSysQueries','SYSTEM TABLE',undef
undef,undef,'MSysRelationships','SYSTEM TABLE',undef
undef,undef,'tst','TABLE',undef
[8 rows of 5 fields returned]
@ado-->


And using DBD::ODBC

T:\projects\DBD-ADO>set DBI_DSN=dbi:ODBC:perl_access

T:\projects\DBD-ADO>dbish
DBI::Shell 11.9 using DBI 1.28
....
Connecting to 'dbi:ODBC:perl_access' as ''...
Loaded plugins DBI::Shell::SQLMinus
@dbi:ODBC:perl_access> /tab
TABLE_CAT,TABLE_SCHEM,TABLE_NAME,TABLE_TYPE,REMARKS
'T:\projects\DBD-ADO\mytest',undef,'MSysAccessObjects','SYSTEM TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'MSysACEs','SYSTEM TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'MSysObjects','SYSTEM TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'MSysQueries','SYSTEM TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'MSysRelationships','SYSTEM TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'demo','TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'demo3','TABLE',undef
'T:\projects\DBD-ADO\mytest',undef,'tst','TABLE',undef
[8 rows of 5 fields returned]
@dbi:ODBC:perl_access>

On Mon, Dec 02, 2002 at 08:53:44PM -0500, Brad Smith wrote:
> Ok, I managed to get the table names of an Access database.  One 
> question, though:  what is all the information in the first few variables of 
> a scalar that read something similar to MSysAccess...?  Do I just need 
> to offset by 5~6 each time I want to display the table names?
> 
> Thanks in advance.
> 
> Brad Smith

-- 
Thomas A. Lowery
See DBI/FAQ http://www.xmlproj.com/cgi/fom.cgi

Reply via email to