[英]what does — and -— mean in mysql?
I know --
means starting of comment in mysql. 我知道
--
意味着在mysql中开始评论。 But what does ---
and ----
mean?? 但是
---
和----
意味着什么? See my console log. 查看我的控制台日志。
mysql> --
mysql> ---
->
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-' at line 1
mysql> ----
->
-> ;
Query OK, 0 rows affected (0.00 sec)
I wrote an sql file that contains header comments started with ---
characters. 我写了一个sql文件,其中包含以
---
字符开头的标题注释。 Due to this next query does not run. 由于这个下一个查询不运行。 It throws error.
它抛出错误。 Like this.
像这样。
ERROR 1064 (42000): You have an error in your SQL syntax;
错误1064(42000):您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '-' at line 1
检查与MySQL服务器版本对应的手册,以便在第1行的“ - ”附近使用正确的语法
There needs to be whitespace or a control character after the second dash. 在第二个破折号之后需要有空格或控制字符。 From the MySQL manual :
从MySQL手册 :
MySQL Server supports three comment styles:
MySQL Server支持三种注释样式:
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).在MySQL中,
--
(双破折号)注释样式要求第二个破折号后跟至少一个空格或控制字符 (例如空格,制表符,换行符等)。 This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.8.5.5, “--
as the Start of a Comment”.此语法与标准SQL注释语法略有不同,如第1.8.5.5节“
--
作为注释的开头”中所述。From a
/*
sequence to the following*/
sequence, as in the C programming language.从
/*
序列到下面的*/
序列,如在C编程语言中。 This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.此语法使注释能够扩展到多行,因为开始和结束序列不必位于同一行。
(Emphasis mine.) And, as usual, this only applies to MySQL. (强调我的。)和往常一样,这只适用于MySQL。 :P
:P
This nothing but syntax check error, 这只是语法检查错误,
Other than '--', mysql considering everything as sql statement. Since
'---' is not a valid statement it's showing error.
that means there should be at least one space after '--' then only it will be considered as valid comment.
Hope this helps you, 希望这能帮到你,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.