The MySQL manual made easy to read and understand
It can, at a first glance, be difficult to understand the MySQL syntax, especially for those new to programming. Here is a brief summary of the conventions used in the MySQL manual. Use it when you first refer to the MySQL manual. It should help make interpreting the syntax easier.
Text in this style is used for
- SQL statements
- database, table, and column names
- program listings and source code
- environment variables
- Example: ?To reload the grant tables, use the
FLUSH PRIVILEGESstatement.?
- Example: ?To reload the grant tables, use the
Text in this style
- indicates the names of executable programs and scripts
- examples being mysql and mysqld
- examples being mysql and mysqld
Text in this style is used for
- variable input for which you should substitute a value of your own choosing.
- Example: ALTER {DATABASE | SCHEMA} [
db_name]alter_specification[alter_specification] ...- here you can optionally include the db_name but have to include at least one
alter_specification you have to include either DATABASE or SCHEMA (schema is synonymous with database)
- here you can optionally include the db_name but have to include at least one
- Example: ALTER {DATABASE | SCHEMA} [
Filenames and directory names are written like this:
- ?The global
my.cnffile is located in the/etcdirectory.?
To specify a wildcard, use the ?%? character.?
Text in this style is used for emphasis
Text in this style is used in
- table headings
- and to convey especially strong emphasis.
shell>
- indicates a command that you execute from your login shell
- Example: shell>
type a shell command here
- Example: shell>
mysql>
- indicates a statement that you execute from the mysql client program
- Example:
mysql> type a mysql statement here
- Example:
The ?shell? is your command interpreter.
- On Unix, this is typically a program such as sh, csh, or bash.
- On Windows, the equivalent program is command.com or cmd.exe, typically run in a console window.
When you enter a command or statement shown in an example, do not type the prompt (mysql> or shell>) shown in the example.
Database, table, and column names must often be substituted into statements.
- the manual uses
db_name,tbl_name, andcol_name.- Example: mysql>
SELECTcol_nameFROMdb_name.tbl_name;- Here you need to supply your own column name, database name and table name
- Example: mysql>
SQL keywords are not case sensitive and may be written in any lettercase. The manual uses UPPERCASE.
Square brackets (?[? and ?]?) indicate optional words or clauses.
- Example DROP TABLE [IF EXISTS]
tbl_nameIF EXISTSis optional and the statement is also valid if written like this:- DROP TABLE
tbl_name
- DROP TABLE
When a syntax element consists of a number of alternatives, the alternatives are separated by vertical bars (?|?).
- If the choice is optional then the alternatives are listed within square brackets (?
[? and ?]?):- Example: TRIM([[BOTH | LEADING | TRAILING] [
remstr] FROM]str)- Here this statement could be written like this, ommiting all the optional alternatives:
- TRIM (str)
- Here this statement could be written like this, ommiting all the optional alternatives:
- Example: TRIM([[BOTH | LEADING | TRAILING] [
- If a choice must be made, the alternatives are listed within braces (?
{? and ?}?):- Example: {DESCRIBE | DESC}
tbl_name[col_name|wild]- Here a choice must be made, so either of these statements is valid:
- DESCRIBE
tbl_name - DESC
tbl_name- you can include either
col_nameorwildas these are optional
- you can include either
- DESCRIBE
- Here a choice must be made, so either of these statements is valid:
- Example: {DESCRIBE | DESC}
An ellipsis (...) indicates the omission of a section of a statement
- to provide a shorter version of more complex syntax.
- Example,
INSERT … SELECTis shorthand for the form ofINSERTstatement that is followed by aSELECTstatement.
- Example,
- also to indicate that the preceding syntax element of a statement may be repeated.
- Example, multiple
reset_optionvalues may be given, with each of those after the first preceded by commas:- RESET
reset_option[,reset_option] …- here it is optional to repeat the
reset_optionafter the ellipsis
- here it is optional to repeat the
- RESET
- Example, multiple