MySQL server support# End of the row,-- The row endsAnd/* The middle of a row or multiple rows */Comment box:
Mysql> select 1 + 1; # This comment ends until the end of the row mysql> select 1 + 1; -- This annotation ends until the end of the row. mysql> select 1/* This is a comment in the middle of the row */+ 1; mysql> select 1 +/* This is a multi-line comment form */1;
Note:-- (Double-length partitioning)Note style requires at least one space after two long strokes!
Although the server understands the annotation syntax just described, the syntax analysis of the mysql client is/*...*/There are limits on the annotation method:
- Single quotes and double quotes are used to mark the beginning of a referenced string, even in a comment. If the quotation marks in the comment are not paired with another one, the syntax analysis program will not consider the comment end. If you run
MySQL, You will be confused, because the prompt fromMysql>Change'>Or">.
- A semicolon is used to indicate the end of the current SQL statement and anything that follows it indicates the start of the next row.
Whether you are running in interactive modeMySQLOr put the command in a file, and thenMysql <some-FileTellMySQLRead its input. This restriction exists.
I think: it is best to use # To start a single line comment, instead of --, because there must be at least one space after the comment. Sometimes an error will occur if you forget to write it!