| User | Host |
+------+--------------------------+
| | localhost |
| root | localhost |
| | saied-ltc.cs.rmit.edu.au |
| root | saied-ltc.cs.rmit.edu.au |
+------+--------------------------+
4 rows inset sec)
We often use this style in this book, because it helps long statements fit in the margins of a page. Notice that the monitor shows you a different prompt (
->
) to indicate that it’s waiting for you to enter more of your SQL statement or to type in a semicolon.
In fact, you can add
whitespace—such as space and tab characters—anywhere between the components of a statement
to improve its formatting, and we often do this in our longer statements. Of course, because whitespace separates keywords and values, you can’t add space within the keywords or
values themselves for example, if you type the keyword
SELECT
as SELECT, you’ll get an error.
In contrast to SQL statements, you can’t span the MySQL monitor’s own commands over more than one line. This is because the semicolon isn’t
actually required for these,
and just pressing the Enter key has the same effect. For example, the
USE
command tells
MySQL that you want to use a particular database. The following works fine:
mysql>
USE testDatabase changed
However, if you try to span the command over more than one line, you won’t get far:
mysql>
USEERROR:
USE must
be followed by a database nameThe Monitor HelpThe monitor has a handy
HELP
command that you can use to get more information on the monitor commands or SQL syntax. If you type
HELP and press the Enter key, you’ll get a list of commands the monitor understands:
mysql> HELP
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including
the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Network Support, training,
or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first online and end with ';'
? (\?) Synonym for `help'.
clear (c) Clear command.
connect (r) Reconnect to the server. Optional arguments are db and host.
delimiter (d) Set statement delimiter. NOTE Takes the rest of the line as new
Share with your friends: