列出mysql的所有存储过程_mysql列出数据库中所有的存储过程

Summary: in this tutorial, we will show you how to list all stored procedures in a MySQL database,and introduce you to a very useful statement that displays stored procedure’s source code.

MySQL provides us with several useful statements that help us to manage stored procedures effectively. Those statements include listing stored procedures and showing the stored procedure’s source code.

Displaying stored procedures characteristics

To display characteristics of a stored procedure, you use the following statement:SHOW PROCEDURE STATUS [LIKE 'pattern' | WHERE expr];

The SHOW PROCEDURE STATUS statement is a MySQL extension to SQL standard. This statement gives you the stored procedure’s characteristics including database, stored procedure name, type, creator and so on.

You can use LIKE or WHERE clause to filter out the stored procedure based on various criteria.

To list all stored procedures of the databases that you have the privilege to access, you use the  SHOW PROCEDURE STATUS statement as follows:SHOW PROCEDURE STATUS;

If you want to show just stored procedure in a particular database, you can use the WHEREclause in the  SHOW PROCEDURE STATUS statement:SHOW PROCEDURE STATUS WHERE db = 'classicmodels';

If you want to show stored procedures that have a particular pattern e.g., its name contains product, you can use the LIKE operator as the following command:SHOW PROCEDURE STATUS WHERE name LIKE '%product%'

Displaying stored procedure’s source code

To display source code of a particular stored procedure, you use the  SHOW CREATE PROCEDURE statement as follows:SHOW CREATE PROCEDURE stored_procedure_name

You specify the name of the stored procedure after the  SHOW CREATE PROCEDURE keywords. For example, to display the code of the GetAllProducts stored procedure, you use the following statement:SHOW CREATE PROCEDURE GetAllProducts

In this tutorial, you have learned some useful statements including  SHOW PROCEDURE STATUS and  SHOW CREATE PROCEDURE statements to list stored procedures in a database and get the source code of the stored procedure.

Related Tutorials

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值