Accessing database metadata
MySQL provides access to several aspects of databases, tables, or extensions thereof. Combining the various options creates the potential for interactive programs, as we will see later in this chapter. As with the MySQL environmental commands, all statements discussed here presume the use of SHOW
.
DATABASES
If you are creating a wholly interactive system for database administration, you will need to access the list of databases. To do this in MySQL, we use the following command:
mysql> SHOW DATABASES;
The result is a single column table showing all known databases on the system to which the user has access. Note that the appearance of a database on the list does not indicate permission to access it. Rather, you would also need to query the privileges of the user, as we will see when accessing user information in the next main section.
Using the USE command
When you have a list of the available databases, you can access a database within the current session using...