Gerry Lawrence


DBIx::Mysql::InformationSchema - Perl module to access the mysql INFORMATION_SCHEMA view, which contains database metadata.


     use DBIx::Mysql::InformationSchema;

Get a new infoschema object.

     my $info_schema = new DBIx::Mysql::InformationSchema ;

Now connect it to the database. The user must have read access to mysql's INFORMATION_SCHEMA view. Print the status if you like.

     print "Mysql information_schema online \n" if $info_schema->{STATUS};

Get a list of all the databases:

     my @databases = $info_schema->databases();

Get a list of tables for a given database:

     my @tables    = $info_schema->tables('any_database');

Get a list of columns for a given database and table:

     my @columns   = $info_schema->tables('any_database','any_table');

Get the metadata for a given database,table and column.

     my $href = $info_schema->column_info('some_database','some_table','some_column');

Get a list of the tables that are in the INFOMATION_SCHEMA view. This is done by querying the INFORMATION_SCHEMA Table, not statically.

     my @itables = $info_schema->information_schema_tables();

Get a list of all the fields in the COLUMNS table in the INFOMATION_SCHEMA view. Like the information_schema_tables function, this is done by querying the INFORMATION_SCHEMA table COLUMNS, not statically.

    my @column_info_rows = $info_schema->column_table_rows();

All done? Then disconnect.



Mysql 5 introduced a system view called INFORMATION_SCHEMA that contains metadata describing the structure of all the databases, tables and columns.

This module provides methods to get at SOME of that data. While you certainly can query the INFORMATION_SCHEMA view manually, if your program uses this data frequently, you may find this module convenient. In order for this to run, you must already have the DBI perl module installed.

This module creates and uses its own database handle, stored in $object->{DBH}. See the dbconnect method. To connect, you must supply a username and password that can read INFORMATION_SCHEMA, which is just about any valid mysql id.

Most of these methods use the COLUMNS table in the information_schema view.

This module exports no variables; all access is via defined functions, therefore I don't use the exporter.


The mysql database --

Perl DBI/DBD/Mysql etc --


Gerry Lawrence, <>


Copyright (C) 2007 by Gerry Lawrence

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.