Obtaining Database and Table Information

You can ask MySQL for several kinds of information about the databases and tables that it supports. It’s possible to get lists of databases and tables, and you can get descriptions about each of the columns in a table. Much of this information is available using various forms of the SHOW statement, a MySQL-specific query that we’ll examine in some detail in the next few sections.

Listing Databases and Tables

To get a list of databases hosted by a MySQL server, use the SHOW DATABASES query. If you want to know what tables are in a particular database, use SHOW TABLES FROM db_name . If you’re writing an interactive query builder, for example, you might let the user first pick a table from the current database, ...

Get MySQL and Perl for the Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.