Chapter 6. MySQL Language Reference
MySQL has a very complex but intuitive and easy-to-learn SQL interface. This chapter describes the various commands, types, and functions you will need to know in order to use MySQL efficiently and effectively. This chapter also serves as a reference to all functionality included in MySQL. In order to use this chapter effectively, you may find it useful to refer to the various indexes.
Language Structure
Literals: How to Write Strings and Numbers
This section describes the various ways to write strings and numbers in MySQL. It also covers the various nuances and “gotchas” that you may run into when dealing with these basic types in MySQL.
Strings
A string is a sequence of characters, surrounded by either single quote (') or double quote (“) characters (only the single quote if you run in ANSI mode). Examples:
'a string' "another string"
Within a string, certain sequences have special meaning. Each of these
sequences begins with a backslash (\), known as the escape
character. MySQL recognises the following escape sequences:
- \0
An ASCII 0 (NUL) character.
- \'
A single quote (') character.
- \"
A double quote (
") character.- \b
A backspace character.
- \n
A newline character.
- \r
A carriage return character.
- \t
A tab character.
- \z
ASCII(26) (Control-Z). This character can be encoded to allow you to work around the problem that ASCII(26) stands for END-OF-FILE on Windows. (ASCII(26) will cause problems if you try to use mysql database < filename.)
- \\
A backslash ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access