Lista de Procedimientos/Funciones Almacenados Mysql Línea de Comandos


¿Cómo puedo ver la lista de los procedimientos almacenados o funciones almacenadas en la línea de comandos de mysql como show tables; o show databases; comandos.

Author: Pranav 웃, 2009-04-09

15 answers

SHOW PROCEDURE STATUS;
SHOW FUNCTION STATUS;
 661
Author: fredrik,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-29 09:56:23
show procedure status

Le mostrará los procedimientos almacenados.

show create procedure MY_PROC

Le mostrará la definición de un procedimiento. Y

help show

Le mostrará todas las opciones disponibles para el comando show.

 192
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-04-09 08:52:40

Para el procedimiento de vista en nombre wise

select name from mysql.proc 

El código inferior se usa para enumerar todo el procedimiento y el código inferior es dar el mismo resultado que mostrar el estado del procedimiento

select * from mysql.proc 
 77
Author: Praveenkumar_V,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-26 05:01:43

Una forma más específica:

SHOW PROCEDURE STATUS 
WHERE Db = DATABASE() AND Type = 'PROCEDURE'
 37
Author: sassman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-05-02 22:53:43

Como se mencionó anteriormente,

show procedure status;

Mostrará una lista de procedimientos, pero muestra todos de ellos, en todo el servidor.

Si quieres ver solo los que están en una sola base de datos, prueba esto:

SHOW PROCEDURE STATUS WHERE Db = 'databasename';
 24
Author: Drarok,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-11-09 09:48:58

Alternativa:

SELECT * FROM INFORMATION_SCHEMA.ROUTINES
 23
Author: macio.Jun,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-02-13 16:21:26

Mi preferencia es por algo que:

  1. Enumera tanto las funciones como los procedimientos,
  2. Me permite saber cuáles son cuáles,
  3. Da los nombres y tipos de los procedimientos y nada más ,
  4. Filtra los resultados por la base de datos actual, no por el definidor actual
  5. Ordena el resultado

Juntando otras respuestas en este hilo, termino con

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

... que termina con resultados que parecen esto:

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)
 15
Author: John Haugeland,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-18 17:17:11

Usa esto:

SHOW PROCEDURE STATUS;
 13
Author: Code Lღver,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-30 12:17:48

Para mostrar solo el tuyo:

SELECT
  db, type, specific_name, param_list, returns
FROM
  mysql.proc
WHERE
  definer LIKE
  CONCAT('%', CONCAT((SUBSTRING_INDEX((SELECT user()), '@', 1)), '%'));
 7
Author: Charlie Skilbeck,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-29 10:03:58

Una variación del post de Praveenkumar_V:

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

..y esto porque necesitaba ahorrar tiempo después de un poco de limpieza:

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';
 7
Author: trapper_hag,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-12 10:26:38
SELECT specific_name FROM `information_schema`.`ROUTINES` WHERE routine_schema='database_name'
 6
Author: Sunil Kumar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-06 14:08:15

Si desea enumerar el Procedimiento de Almacenamiento para la Base de Datos Seleccionada Actual,

SHOW PROCEDURE STATUS WHERE Db = DATABASE();

Enumerará Rutinas basadas en la Base de datos seleccionada actual

 3
Author: Mohideen ibn Mohammed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-12 06:59:29
SHOW PROCEDURE STATUS;

Muestra todos los procedimientos almacenados.

SHOW FUNCTION STATUS;

Muestra todas las funciones.

SHOW CREATE PROCEDURE [PROC_NAME];

Mostrará la definición del procedimiento especificado.

SHOW PROCEDURE STATUS WHERE Db = '[db_name]';

Le mostrará todos los procedimientos de la base de datos dada.

 1
Author: Optimizer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-07 05:22:14
                           show procedure status;

Usando este comando puede ver todos los procedimientos en las bases de datos

 0
Author: Karan Rajput,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-22 07:26:41

Utilice la siguiente consulta para todos los procedimientos:

select * from sysobjects 
where type='p'
order by crdate desc
 -3
Author: mwesigwa,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-06-11 08:27:04