如何评论sp mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13949554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:50:17  来源:igfitidea点击:

how to comment sp mysql

mysqlstored-procedurescomments

提问by John Christy

Am trying to comment an sp using MySQL workbench I tried with the following syntax.

我正在尝试使用 MySQL 工作台评论 sp 我尝试使用以下语法。

/**
Hai
*/  

and

-- hai

these two will execute perfectly but changes never updated to SP, while open SP it doesnot shows any changes.

这两个将完美执行,但更改永远不会更新到 SP,而打开 SP 它不会显示任何更改。

Thanks for any help.

谢谢你的帮助。

回答by álvaro González

You should place your comments inside the procedure body, i.e., what's between BEGINand END. The rest of the code are instructions to create the procedure and are lost once you run them.

您应该将您的评论放在程序主体内,即,BEGIN和之间的内容END。其余代码是创建过程的说明,一旦运行它们就会丢失。

Comment syntax is as usual:

注释语法和往常一样:

  • /* ... */
  • --<space>
  • /* ... */
  • --<space>

MySQL Workbench conveniently warns about this:

MySQL Workbench 很方便地对此发出警告:

enter image description here

在此处输入图片说明

回答by fancyPants

MySQL has a comment feature. Official manual here.

MySQL 具有注释功能。官方手册在这里

Example:

例子:

DELIMITER $$
CREATE PROCEDURE proc_name()
COMMENT 'this is my comment'
BEGIN
/*here comes my voodoo*/
END $$
DELIMITER ;

This way you also save the comment in the database, not just in your source code.

通过这种方式,您还可以将评论保存在数据库中,而不仅仅是在源代码中。