List of Stored Procedures/Functions Mysql Command

2019-01-08 02:53发布

How can I see the list of the stored procedures or stored functions in mysql command line like show tables; or show databases; commands.

15条回答
乱世女痞
2楼-- · 2019-01-08 03:18

A variation on Praveenkumar_V's post:

SELECT `name` FROM mysql.proc WHERE db = 'dbname' AND `type` = 'PROCEDURE';
SELECT `name` FROM mysql.proc WHERE db = 'dbname' AND `type` = 'FUNCTION';

..and this because I needed to save time after some housekeeping:

SELECT CONCAT(
     "GRANT EXECUTE ON PROCEDURE `"
    ,`name`
    ,"` TO username@'%'; -- "
    ,`comment`
)
FROM mysql.proc
WHERE db = 'dbname'
AND `type` = 'PROCEDURE';

SELECT CONCAT(
     "GRANT EXECUTE ON FUNCTION `"
    ,`name`
    ,"` TO username@'%'; -- "
    ,`comment`
)
FROM mysql.proc
WHERE db = 'dbname'
AND `type` = 'FUNCTION';
查看更多
手持菜刀,她持情操
3楼-- · 2019-01-08 03:19

If you want to list Store Procedure for Current Selected Database,

SHOW PROCEDURE STATUS WHERE Db = DATABASE();

it will list Routines based on current selected Database

查看更多
来,给爷笑一个
4楼-- · 2019-01-08 03:22
SELECT specific_name FROM `information_schema`.`ROUTINES` WHERE routine_schema='database_name'
查看更多
Melony?
5楼-- · 2019-01-08 03:23

To show just yours:

SELECT
  db, type, specific_name, param_list, returns
FROM
  mysql.proc
WHERE
  definer LIKE
  CONCAT('%', CONCAT((SUBSTRING_INDEX((SELECT user()), '@', 1)), '%'));
查看更多
6楼-- · 2019-01-08 03:24
                           show procedure status;

using this command you can see the all procedures in databases

查看更多
一纸荒年 Trace。
7楼-- · 2019-01-08 03:25

A more specific way:

SHOW PROCEDURE STATUS 
WHERE Db = DATABASE() AND Type = 'PROCEDURE'
查看更多
登录 后发表回答