Appendix D. SQL Syntax Reference

Appendix D. SQL Syntax Reference

This appendix describes

  • Each of the SQL statements provided by MySQL

  • How to set and use user-defined variables within SQL statements

  • The syntax for writing comments in SQL code. Comments are used to write descriptive text that is ignored by the server and to hide MySQL-specific keywords (these keywords will be executed by MySQL but ignored by other database servers).

MySQL development is ongoing, so enhancements to its SQL implementation are made on a continuing basis. You will find it useful to consult the online MySQL Reference Manual at occasionally to see what new capabilities are being added.

The syntax descriptions use the following conventions:

  • Optional information is enclosed in square brackets ([]).

  • Vertical bars (|) separate alternative items in a list. If a list is enclosed in square brackets, one alternative may be chosen. If a list is enclosed in curly brackets ({}), one alternative must be chosen.

  • Ellipsis notation (…) indicates that the term preceding the ellipsis can be repeated.

  • n indicates an integer.

  • 'string' indicates a string value. A single-quoted value such as 'file_name' or 'pattern' indicates a more specific kind of value, such as a filename or a pattern.

Unless otherwise indicated, the statements listed here have been present in MySQL at least as far back as MySQL 3.22.0.