w

https://dev.mysql.com/doc/refman/5.7/en/comments.html

MySQL 5.7 Reference Manual  /  Language Structure  /  Comment Syntax

10.6 Comment Syntax

MySQL Server supports three comment styles:

  • 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). This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.8.2.4, “'--' as the Start of a Comment”.

  • From a /* sequence to the following */ sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.

The following example demonstrates all three 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;

Nested comments are not supported. (Under some conditions, nested comments might be permitted, but usually are not, and users should avoid them.)

MySQL Server supports some variants of C-style comments. These enable you to write code that includes MySQL extensions, but is still portable, by using comments of the following form:

/*! MySQL-specific code */

In this case, MySQL Server parses and executes the code within the comment as it would any other SQL statement, but other SQL servers will ignore the extensions. For example, MySQL Server recognizes the STRAIGHT_JOIN keyword in the following statement, but other servers will not:

SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...

If you add a version number after the ! character, the syntax within the comment is executed only if the MySQL version is greater than or equal to the specified version number. The TEMPORARY keyword in the following comment is executed only by servers from MySQL 5.1.10 or higher:

CREATE TABLE t1(a INT, KEY (a)) /*!50110 KEY_BLOCK_SIZE=1024 */;

The comment syntax just described applies to how the mysqld server parses SQL statements. The mysql client program also performs some parsing of statements before sending them to the server. (It does this to determine statement boundaries within a multiple-statement input line.)

Comments in this format, /*!12345 ... */, are not stored on the server. If this format is used to comment stored routines, the comments will not be retained on the server.

Another variant of C-style comment syntax is used to specify optimizer hints. Hint comments include a + character following the /* comment opening sequence. Example:

SELECT /*+ BKA(t1) */ FROM ... ;

For more information, see Section 9.9.2, “Optimizer Hints”.

The use of short-form mysql commands such as \C within multiple-line /* ... */ comments is not supported.

最新文章

  1. 决定如何开发你的WordPress主题框架
  2. Windows7下安装搭建redis教程和配置详解
  3. Hadoop初步认识
  4. JDBC、Hibernate、Mybaites处理数据的流程及对DAO的理解
  5. linux安装GraphicsMagick
  6. js截取文件名
  7. redhat 6.8 配置centos6的yum源
  8. 201521123052《Java程序设计》第5周学习总结
  9. 【ASP】response和sever对象实现用户登录
  10. 授权普通非DBA用户可以有权限查看执行计划的方法
  11. vue- 项目之前端页面搭建1
  12. Oja’s rule
  13. Spring Boot 揭秘与实战(二) 数据存储篇 - 声明式事务管理
  14. 20155302《网络对抗》Exp8 Web基础
  15. 2013长春网赛1004 hdu 4762 Cut the Cake
  16. windows下如何生成gitlab ssh公钥
  17. 放苹果问题 DP计数 m个苹果放在n个盘子里,苹果,盘子相同,盘子可为空
  18. 用虚拟机安装了一台Linux系统,突然想克隆一台服务器,克隆后发现无法上网,如何解决?
  19. c# 网站 vislual studio
  20. UDP也需要现有Server端,然后再有Client端

热门文章

  1. linux获取外网ip
  2. Lucene整理--中文分词
  3. git的配置设置
  4. 使用css3的repeating-linear-gradient画虚线
  5. document.getElementsByTagName()方法的返回值
  6. mktemp - 产生唯一的临时文件名
  7. RK3288之kernel目录结构以及功能
  8. 01JAVA入门
  9. hdu 1505 单调栈升级版
  10. GUI学习之二十七——布局管理学习总结