如何在mysql命令行中看到存储过程或存储函数的列表,如show tables;或显示数据库;命令。


当前回答

SELECT specific_name FROM `information_schema`.`ROUTINES` WHERE routine_schema='database_name'

其他回答

选择:

SELECT * FROM INFORMATION_SCHEMA.ROUTINES

更具体的说法:

SHOW PROCEDURE STATUS 
WHERE Db = DATABASE() AND Type = 'PROCEDURE'

对所有过程使用以下查询:

select * from sysobjects 
where type='p'
order by crdate desc
SELECT specific_name FROM `information_schema`.`ROUTINES` WHERE routine_schema='database_name'

我的偏好是:

列出了函数和过程, 让我知道哪个是哪个, 只给出过程的名称和类型, 根据当前数据库而不是当前定义器筛选结果 对结果进行排序

把这篇文章中的其他答案拼接在一起,我最终得到了

select 
  name, type 
from 
  mysql.proc 
where 
  db = database() 
order by 
  type, name;

... 最终你会得到这样的结果:

mysql> select name, type from mysql.proc where db = database() order by type, name;
+------------------------------+-----------+
| name                         | type      |
+------------------------------+-----------+
| get_oldest_to_scan           | FUNCTION  |
| get_language_prevalence      | PROCEDURE |
| get_top_repos_by_user        | PROCEDURE |
| get_user_language_prevalence | PROCEDURE |
+------------------------------+-----------+
4 rows in set (0.30 sec)