在 MySql 中显示过程/函数代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12104884/
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
Show procedure/function code in MySql
提问by User129
Is there any options to view stored procedure/function code in MySql same as like "sp_helptext procedurename" in sql?
是否有任何选项可以像 sql 中的“sp_helptext procedurename”一样查看 MySql 中的存储过程/函数代码?
回答by codelization
try "SHOW CREATE PROCEDURE procedurename"
尝试“显示创建程序程序名称”
回答by Christoph
Yes,
是的,
SELECT ROUTINE_DEFINITION FROM information_schema.ROUTINES WHERE SPECIFIC_NAME='procedurename'
回答by David A. Gray
I've been experimenting a bit, and I think one of the following two works best.
我一直在进行一些试验,我认为以下两种方法中的一种效果最好。
To list everything (parameters, collating, etc.), use this.
要列出所有内容(参数、整理等),请使用它。
SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA in (SELECT DATABASE()) AND ROUTINE_NAME='ProcedureName';
To list only the code, use this.
要仅列出代码,请使用它。
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA in (SELECT DATABASE()) AND ROUTINE_NAME='ProcedureName';
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA in (SELECT DATABASE()) AND ROUTINE_NAME='ProcedureName';
In both of the above, the nested select is required to limit the result to the current data base, since INFORMATION_SCHEMA, being the system data base, contains details for every data base installed in the instance.
在上述两种情况下,都需要嵌套选择将结果限制到当前数据库,因为 INFORMATION_SCHEMA 作为系统数据库,包含实例中安装的每个数据库的详细信息。
回答by Raman Verma
Go to mySQL workbench
转到 mySQL 工作台
- Right click on procedure and then select ALTER. (This Will open the definition of procedure for you(is the easiest way).
- 右键单击程序,然后选择ALTER。(这将为您打开程序定义(这是最简单的方法)。
OR
或者
- You can also use the command, SHOW
CREATE PROCEDURE proc_name
;
- 您也可以使用命令 SHOW
CREATE PROCEDURE proc_name
;
回答by Maxim Krizhanovsky
You can get the information form the INFORMATION_SCHEMA.ROUTINES table
您可以从INFORMATION_SCHEMA.ROUTINES 表中获取信息