Learning Mysql


Style, Case, and Semicolons



Download 4.24 Mb.
View original pdf
Page93/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   89   90   91   92   93   94   95   96   ...   366
Learning MySQL
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 capitals, 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 readable and easier to follow in source code and books.
MySQL isn’t fussy about whether you enter SQL or the monitor’s proprietary statements 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 lowercase 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 book.
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 characters 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

Download 4.24 Mb.

Share with your friends:
1   ...   89   90   91   92   93   94   95   96   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page