我如何在MySQL中添加注释?

我想在SQL代码中添加注释。 我怎样才能做到这一点? 我正在使用MySQL。

几种方法:

# Comment -- Comment /* Comment */ 

看文档 。

“注释可以用COMMENT选项来指定, COMMENTSHOW CREATE TABLESHOW FULL COLUMNS语句显示,这个选项在MySQL 4.1以前是可用的(在早期版本中允许但是忽略)。

举个例子

 -- -- Table structure for table 'accesslog' -- CREATE TABLE accesslog ( aid int(10) NOT NULL auto_increment COMMENT 'unique ID for each access entry', title varchar(255) default NULL COMMENT 'the title of the page being accessed', path varchar(255) default NULL COMMENT 'the local path of teh page being accessed', .... ) TYPE=MyISAM; 

您可以使用单行注释:

 -- this is a comment # this is also a comment 

或者多行评论:

 /* multiline comment */ 

从这里你可以使用

 # For single line comments -- Also for single line, must be followed by space/control character /* C-style multiline comment */ 

支持三种types的评论

  1. 散列基础单行注释使用#

     Select * from users ; # this will list users 
    1. 双重短跑评论使用 –

    Select * from users ; -- this will list users

注意:重要的是有一个单一的空白后 –

3)多行注释使用/ * * /

 Select * from users ; /* this will list users */ 
 /* comment here */ 

这里是一个例子: SELECT 1 /* this is an in-line comment */ + 1;

http://dev.mysql.com/doc/refman/5.0/en/comments.html