Databases Reference
In-Depth Information
| mysql |
| test |
+----------+
2 rows in set (0.00 sec)
You may see different results on your MySQL server. There are two databases here; the
mysql database is used to store information about user access privileges, and the test
database is an empty scratch space for experimentation. Not terribly exciting, but you'll
remedy this situation as you progress through this topic!
Style, Case, and Semicolons
When interacting with a MySQL server, you'll use a combination of SQL keywords,
MySQL proprietary commands, and names of databases and database components.
We follow common convention and use a style to make it easier to distinguish between
components of an SQL query. We always show SQL statements and keywords in cap-
itals, such as SELECT or FROM . We also show the MySQL monitor's proprietary SQL
commands—such as USE —in uppercase. We always enter database components—such
as database, table, and column names—in lowercase. This makes our SQL more read-
able and easier to follow in source code and topics.
MySQL isn't fussy about whether you enter SQL or the monitor's proprietary state-
ments in uppercase or lowercase. For example, SELECT , select , Select , and even
SeLeCt are equivalent. However, depending on your platform, MySQL can be fussy
about database and table names. For example, under Windows, MySQL isn't fussy at
all (because Windows itself isn't fussy about the filenames that store those structures),
while on Mac OS X its fussiness depends on what underlying filesystem you use to store
disk files. Linux and Unix systems observe the difference between uppercase and low-
ercase strictly. A reliable approach is to adopt the convention of using lowercase for all
database, table, and column names. You can control how MySQL manages different
case behavior using an option when you start the MySQL server, mysqld , but we don't
recommend you do this, and we don't discuss it further in this topic.
There are some restrictions on what characters and words you can use in your database,
table, and other names. For example, you can't have a column named from or select
(in any mix of uppercase and lowercase). These restrictions are mostly obvious, since
they apply to reserved keywords that confuse MySQL's parser. We discuss the char-
acters that can and can't be used in Chapter 6.
You'll notice that we terminate all SQL statements with the semicolon character ( ; ).
This tells MySQL that we've finished entering a statement and that it should now parse
and execute it. This gives you flexibility, allowing you to type in a statement over several
lines. For example, the following statement works fine:
mysql> SELECT User,Host
-> FROM user;
+------+--------------------------+
 
Search WWH ::




Custom Search