如何在mysql命令行show tables;
或show databases;
命令中查看存储过程或存储函数的列表.
SHOW PROCEDURE STATUS; SHOW FUNCTION STATUS;
show procedure status
将显示存储过程.
show create procedure MY_PROC
将向您展示程序的定义.和
help show
将显示该show
命令的所有可用选项.
以名义方式查看过程
select name from mysql.proc
下面用于列出所有过程的代码,下面的代码与show procedure status给出相同的结果
select * from mysql.proc
更具体的方式:
SHOW PROCEDURE STATUS WHERE Db = DATABASE() AND Type = 'PROCEDURE'
正如刚才提到的,
show procedure status;
确实会显示一个程序列表,但在服务器范围内显示所有这些程序.
如果您只想查看单个数据库中的那些,请尝试以下方法:
SHOW PROCEDURE STATUS WHERE Db = 'databasename';
替代方案:
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
我的偏好是:
列出功能和程序,
让我知道哪些是,
给出程序的名称和类型,没有别的,
过滤当前数据库的结果,而不是当前的定义者
对结果进行排序
从这个帖子中的其他答案拼凑而成,我最终得到了
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 PROCEDURE STATUS;
显示所有功能:
SHOW FUNCTION STATUS;
显示指定过程的定义:
SHOW CREATE PROCEDURE [PROC_NAME];
显示给定数据库的所有过程:
SHOW PROCEDURE STATUS WHERE Db = '[db_name]';
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 db, type, specific_name, param_list, returns FROM mysql.proc WHERE definer LIKE CONCAT('%', CONCAT((SUBSTRING_INDEX((SELECT user()), '@', 1)), '%'));
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";