如何在mysql命令行中看到存储过程或存储函数的列表,如show tables;或显示数据库;命令。
当前回答
我的偏好是:
列出了函数和过程, 让我知道哪个是哪个, 只给出过程的名称和类型, 根据当前数据库而不是当前定义器筛选结果 对结果进行排序
把这篇文章中的其他答案拼接在一起,我最终得到了
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)
其他回答
更具体的说法:
SHOW PROCEDURE STATUS
WHERE Db = DATABASE() AND Type = 'PROCEDURE'
我的偏好是:
列出了函数和过程, 让我知道哪个是哪个, 只给出过程的名称和类型, 根据当前数据库而不是当前定义器筛选结果 对结果进行排序
把这篇文章中的其他答案拼接在一起,我最终得到了
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)
SHOW PROCEDURE STATUS;
SHOW FUNCTION STATUS;
我最喜欢呈现的程序列表的当前数据库:名称,参数列表,注释
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';
如果要列出当前所选数据库的存储过程,请
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";