Home >Database >Mysql Tutorial >What are the comment characters of mysql?
There are three types of comment characters in mysql: 1. "#", which represents a single-line comment, and the syntax is "#comment content"; 2. "--", which represents a single-line comment and the syntax is "--comment content"; 3. "/**/", indicating multi-line comments, the syntax "/*comment content*/".
The operating environment of this tutorial: windows7 system, mysql5.7.27 version, Dell G3 computer.
There are three types of MySQL comment characters:
1, #comment content
, which represents a single line comment
2, "-- Comment content
" (note that there is a space after --)
3, /*Comment content*/
In addition, required Pay attention to the following points:
/* .... */
are comments in most programming languages. The statements in this comment are not executed. However, in order to maintain compatibility in MySQL, for example, the SQL statements exported from mysqldump can be used directly by other databases, it places some unique statements that are only on MySQL in/*! ... */
, so that these statements will not be executed in other databases, but they will be executed in MySQL. Here, there can be no space between*
and!
.Statements such as "
/*!50701 select * from test */;
", 50701 here means that the statement will be executed only if the database server is version 5.7.01 or above.
The example is as follows:
MySQL [(none)]> /*!select count(*) from mysql.user*/; +----------+ | count(*) | +----------+ | 7 | +----------+ 1 row in set (0.07 sec) MySQL [(none)]> /* !select count(*) from mysql.user*/; ERROR: No query specified MySQL [(none)]> /* select count(*) from mysql.user*/; ERROR: No query specified MySQL [(none)]> select @@version; +--------------+ | @@version | +--------------+ | 5.7.27-5-log | +--------------+ 1 row in set (0.06 sec) MySQL [(none)]> /*!50727 select count(*) from mysql.user*/; +----------+ | count(*) | +----------+ | 7 | +----------+ 1 row in set (0.08 sec) MySQL [(none)]> /*!50728 select count(*) from mysql.user*/; Query OK, 0 rows affected (0.06 sec)
The MySQL server version is 5.7.27. When the MySQL server version is greater than or equal to 5.7.28, the last SQL statement will be executed.
[Related recommendations: mysql video tutorial]
The above is the detailed content of What are the comment characters of mysql?. For more information, please follow other related articles on the PHP Chinese website!