Home  >  Article  >  Database  >  Mysql中语句如何注释_MySQL

Mysql中语句如何注释_MySQL

WBOY
WBOYOriginal
2016-06-01 13:09:501203browse

MySQL服务器支持3种注释风格:

·         从‘#’字符从行尾。

·         从‘-- ’序列到行尾。请注意‘-- ’(双破折号)注释风格要求第2个破折号后面至少跟一个空格符(例如空格、tab、换行符等等)。该语法与标准SQL注释语法稍有不同,后者将在1.8.5.7, “‘--’作为注释起始标记”中讨论。

·         从/*序列到后面的*/序列。结束序列不一定在同一行中,因此该语法允许注释跨越多行。

下面的例子显示了3种风格的注释:

mysql> <strong>SELECT 1+1;     # This comment continues to the end of line</strong>
mysql> <strong>SELECT 1+1;     -- This comment continues to the end of line</strong>
mysql> <strong>SELECT 1 /* this is an in-line comment */ + 1;</strong>
mysql> <strong>SELECT 1+</strong>
/*
this is a
multiple-line comment
*/
1;

上述的注释语法适用于mysqld服务器如何分析SQL语句。发送到服务器之前,mysql客户程序也执行部分语句解析。(例如,它通过解析来确定在多语句行中的语句边界)。

在MySQL 5.1中,mysql解析/* ...*/注释的唯一局限性是结合该风格的注释定界符使用的叹号标记了有条件执行的SQL语句部分。适用于交互式运行mysql和将命令放入一个文件中,并以批处理模式使用mysql来处理mysql file_name的文件。详细信息和例子参见1.8.4节,“MySQL对标准SQL的扩展”。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn