Rechercher dans le manuel MySQL
9.6 Comment Syntax
MySQL Server supports three comment styles:
From a
#
character to the end of the line.From a
--
sequence to the end of the line. In MySQL, the--
(double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on). This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.8.2.4, “'--' as the Start of a Comment”.From a
/*
sequence to the following*/
sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.
The following example demonstrates all three comment styles:
- /*
- this is a
- multiple-line comment
- */
- 1;
Nested comments are not supported, are deprecated, and will be removed in a future MySQL release. (Under some conditions, nested comments might be permitted, but usually are not, and users should avoid them.)
MySQL Server supports some variants of C-style comments. These enable you to write code that includes MySQL extensions, but is still portable, by using comments of the following form:
- /*! MySQL-specific code */
In this case, MySQL Server parses and executes the code within the
comment as it would any other SQL statement, but other SQL servers
will ignore the extensions. For example, MySQL Server recognizes
the STRAIGHT_JOIN
keyword in the following
statement, but other servers will not:
If you add a version number after the !
character, the syntax within the comment is executed only if the
MySQL version is greater than or equal to the specified version
number. The KEY_BLOCK_SIZE
keyword in the
following comment is executed only by servers from MySQL 5.1.10 or
higher:
The comment syntax just described applies to how the mysqld server parses SQL statements. The mysql client program also performs some parsing of statements before sending them to the server. (It does this to determine statement boundaries within a multiple-statement input line.) For information about differences between the server and mysql clinet parsers, see Section 4.5.1.6, “mysql Client Tips”.
Comments in /*!12345 ... */
format are not
stored on the server. If this format is used to comment stored
programs, the comments are not retained in the program body.
Another variant of C-style comment syntax is used to specify
optimizer hints. Hint comments include a +
character following the /*
comment opening
sequence. Example:
For more information, see Section 8.9.3, “Optimizer Hints”.
The use of short-form mysql commands such as
\C
within multiple-line /* ...
*/
comments is not supported.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-comments.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.