Answers:
show procedure status
将向您显示存储过程。
show create procedure MY_PROC
将向您显示过程的定义。和
help show
将显示该show
命令的所有可用选项。
用于以明智的方式查看程序
select name from mysql.proc
下面的代码用于列出所有过程,下面的代码给出与显示过程状态相同的结果
select * from mysql.proc
select db,name,type from mysql.proc where db<>'sys';
为更多的信息,并减少了内置的系统kruft。
更具体的方法:
SHOW PROCEDURE STATUS
WHERE Db = DATABASE() AND Type = 'PROCEDURE'
正如刚才提到的,
show procedure status;
确实会显示一个过程列表,但会在服务器范围内显示所有过程。
如果您只想查看单个数据库中的数据库,请尝试以下操作:
SHOW PROCEDURE STATUS WHERE Db = 'databasename';
我的偏好是:
从这个线程中的其他答案中缝合在一起,我最终得到了
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)
Praveenkumar_V的帖子的一个变体:
SELECT `name` FROM mysql.proc WHERE db = 'dbname' AND `type` = 'PROCEDURE';
SELECT `name` FROM mysql.proc WHERE db = 'dbname' AND `type` = 'FUNCTION';
..这是因为在整理后我需要节省时间:
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';
SELECT specific_name FROM `information_schema`.`ROUTINES` WHERE routine_schema='database_name'
如果要列出当前所选数据库的存储过程,
SHOW PROCEDURE STATUS WHERE Db = DATABASE();
它将基于当前选定的数据库列出例程
更新 以列出数据库中的功能
select * from information_schema.ROUTINES where ROUTINE_SCHEMA="YOUR DATABASE NAME" and ROUTINE_TYPE="FUNCTION";
列出数据库中的例程/存储过程,
select * from information_schema.ROUTINES where ROUTINE_SCHEMA="YOUR DATABASE NAME" and ROUTINE_TYPE="PROCEDURE";
列出数据库中的表,
select * from information_schema.TABLES WHERE TABLE_TYPE="BASE TABLE" AND TABLE_SCHEMA="YOUR DATABASE NAME";
列出数据库中的视图,
方法1:
select * from information_schema.TABLES WHERE TABLE_TYPE="VIEW" AND TABLE_SCHEMA="YOUR DATABASE NAME";
方法2:
select * from information_schema.VIEWS WHERE TABLE_SCHEMA="YOUR DATABASE NAME";
我最喜欢的当前数据库程序列表的渲染:名称,参数列表,注释
SELECT specific_name AS name, param_list AS params, `comment`
FROM mysql.proc
WHERE db = DATABASE()
AND type = 'PROCEDURE';
添加函数的收益:
SELECT specific_name AS name, param_list AS params, `returns`, `comment`
FROM mysql.proc
WHERE db = DATABASE()
AND type = 'FUNCTION';
列出所有数据库的用户过程和功能:
SELECT
`ROUTINE_SCHEMA` AS `database`
,`ROUTINE_TYPE` AS `type`
,`SPECIFIC_NAME` AS `name`
,`DTD_IDENTIFIER` AS `data_type`
FROM
`INFORMATION_SCHEMA`.`ROUTINES`
WHERE
`definer` LIKE
CONCAT('%', CONCAT((SUBSTRING_INDEX((SELECT user()), '@', 1)), '%'))
ORDER BY
`database`
,`type`
,`name`
;
列出用户正在使用的数据库的过程和功能:
SELECT
`ROUTINE_SCHEMA` AS `database`
,`ROUTINE_TYPE` AS `type`
,`SPECIFIC_NAME` AS `name`
,`DTD_IDENTIFIER` AS `data_type`
FROM
`INFORMATION_SCHEMA`.`ROUTINES`
WHERE
`definer` LIKE
CONCAT('%', CONCAT((SUBSTRING_INDEX((SELECT user()), '@', 1)), '%'))
AND
`ROUTINE_SCHEMA` = DATABASE()
ORDER BY
`type`
,`name`
;
object_name(@@procid)
在SSMS中在MySql中是这样的吗?