Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1

Figure 2.5 Viewing existing databases in the MySQL monitor.
To commit the action or SQL statement you have typed, you must end your line with either a semicolon
(;) or a \g. This tells the MySQL monitor that you have finished your command and are ready to
execute it. Simply pressing the Return or Enter key causes a line feed. This allows you to enter a long
SQL string legibly. Another nice feature is the recall button. For Linux users, the up arrow will recall the
last lines you have typed, just like the system. It uses a different history file than the operating system,
so the only commands that are recalled are the commands that were typed at the MySQL prompt. For
Windows users, well, we're just out of luck. There is no history recall key (not even the F3 key—the
normal recall key for DOS). The recall key is extremely convenient, especially when you make an error
in a long SQL query. There isn't a lot of re-typing.
To work with a listed database, you must tell the MySQL monitor which one to use. The command is
simple enough. Type the following to use the mysql database:
USE mysql;
You should see output similar to that shown in Figure 2.


Figure 2.6 Results of the USE command.


To see the structure or schema of a database, issue the following command:
SHOW TABLES FROM mysql;
The output should resemble Figure 2.7.
Free download pdf