如何列出mysql存储过程参数 [英] How to list mysql stored procedure parameters
问题描述
列出MySQL存储过程的参数的SQL是什么? information_schema.routines
表保存了存储过程的名称,但是似乎没有标准的位置存储参数.
What is the SQL to list the parameters of a MySQL stored procdure? The information_schema.routines
table holds the stored procedure names but there doesn't seem to be a standard place where the parameters are stored.
推荐答案
More recent versions of MySQL (5.5.3 and above) introduced the information_schema.parameters object which should give you the information you need;
SELECT *
FROM information_schema.parameters
WHERE SPECIFIC_NAME = 'your_procedure';
早期版本的MySql依赖于对mysql.proc表的访问; "param_list"列中包含您所关注的过程名称的所有参数信息.但是,由于该信息存储为逗号分隔的字符串,因此该信息绝对未归一化:
Earlier versions of MySql rely on having access to the mysql.proc table; the column 'param_list' has all of the parameter information in there for the procedure with the name you are interested in. The information is decidedly non-normalised, though, as it is stored as comma separated string:
SELECT param_list FROM mysql.proc WHERE db='your_database' AND name='your_procedure';
赠予:
IN param1 VARCHAR(32), IN param2 int, ...
这需要做更多的工作才能放入演示文稿的格式;尽管string.split函数至少可以整理一下.
This requires some more work to put into a format for presentation; although a string.split function would at least tidy it up.
这篇关于如何列出mysql存储过程参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!