The MySQL server supports the # to end of line
, -- to end of line
and /* in-line or multiple-line */
comment styles:
mysql> select 1+1; # This comment continues to the end of line mysql> select 1+1; -- This comment continues to the end of line mysql> select 1 /* this is an in-line comment */ + 1; mysql> select 1+ /* this is a multiple-line comment */ 1;
Note that the --
comment style requires you to have at least one space after the --
!
Although the server understands the comment syntax just described, there are some limitations on the way that the mysql
client parses /* ... */
comments:
mysql
interactively, you can tell that it has gotten confused like this because the prompt changes from mysql>
to '>
or ">
. These limitations apply both when you run mysql
interactively and when you put commands in a file and tell mysql
to read its input from that file with mysql < some-file
.
MySQL doesn't support the `--' ANSI SQL comment style. See section 5.4.7 `--' as the start of a comment.