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 ...

Get Learning MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.