为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
MySQL

Summary: in this tutorial, we will show you how to list all stored procedures in a MySQL databaseand 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 WHERE clause 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

原文链接:http://outofmemory.cn/mysql/procedure/listing-stored-procedures-in-mysql-database

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消