Geographic FeaturesLanguage Structure
Storage Engines
Stored Routines
Table Maintenance
Transactions
Triggers
You may see more or less help content depending on the help files that have been installed with your server. You can get information on individual topics by typing in the HELP command followed by the topic name. For example, to get information
on data manipulation, you would type:
mysql> HELP Data Manipulation
You asked for help about help category "Data Manipulation"
For more information, type 'help
- ', where
- is one of the following topics:
CACHE INDEX
DELETE
EXPLAIN
INSERT
SELECT
SHOW
SHOW CREATE DATABASE
SHOW CREATE TABLE
SHOW DATABASES
SHOW GRANTS
SHOW STATUS
SHOW TABLES
UPDATE
We’ve omitted some items to keep the output short.
You can request further information on any of the items by typing HELP followed by the appropriate keywords. For example, for information on the SHOW DATABASES
com- mand, you’d type:
mysql> HELP SHOW DATABASES
Name: 'SHOW DATABASES'
Description:
Syntax:
SHOW DATABASES | SCHEMAS} LIKE 'pattern']
100 | Chapter 3:
Using the MySQL Monitor
SHOW DATABASES lists the databases on the MySQL server host. You see only those databases for which you have some kind of privilege, unless you have the global SHOW DATABASES privilege. You can also get this list using the mysqlshow command.
If the server was started with the --skip-show-database option, you cannot use this statement at all unless
you have the SHOW DATABASESprivilege.
SHOW SCHEMAS can be used as of MySQL 5.0.2
Running the Monitor in Batch ModeThe MySQL monitor can be used in
interactive mode or in
batch mode. In interactive mode, you type in SQL queries or MySQL commands
such as SHOW DATABASESat the
MySQL prompt, and view the results.
In batch mode, you tell the monitor to read in and execute a list of commands from a file. This is useful when you need to run a large set of operations—for example, when you want to restore a database from a backup file. It’s also useful when you need to run a particular sequence of operations frequently you can save the commands in a file and then tell the monitor to read in the file whenever you need it.
The examples we’ve presented earlier in this chapter, and most of the examples in this book, show the monitor being used in interactive mode. Let’s look at an example for batch mode. Say
you have a text file called count_users.sql containing the SQL
commands:
use mysql;
SELECT COUNT) FROM user;
This script tells MySQL that you want to use the mysql database, and that you want to count all the users who have accounts on the MySQL server (well explain the syntax of the SELECT command in Chapter You can run all the commands
in this file using the SOURCE
command:
mysql>
SOURCE count_users.sqlDatabase changed count) |
+----------+
| 4 |
+----------+
1 row inset sec)
If the
count_users.sql file isn’t in the current directory, you should give the full path to the file—for example,
/home/adam/Desktop/count_users.sql or
C:\count_users.sql. Alternatively, from the command line, you can use the less-than (<) redirection operator followed by the filename:
Share with your friends: