Comment Syntax

This section describes how to write comments in your SQL code. It also points out a shortcoming of the mysql client program with respect to comment interpretation. Comments are often used in query files that are executed using mysql in batch mode, so you should be particularly aware of this limitation when you're writing such files.

The MySQL server understands three types of comments:

  • Anything from '#' to the end of the line is treated as a comment. This syntax is the same as is used in most shells and Perl.

  • Anything between '/*' and '*/' is treated as a comment. This form of comment may span multiple lines. This syntax is the same as is used in the C language.

  • As of MySQL 3.23.3, you can begin a comment with '-- ' (two dashes ...

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