snippetsqlMajor
How do I find out if a procedure or function exists in a mysql database?
Viewed 0 times
howexistsfunctionproceduredatabasemysqlfindout
Problem
How do I find out if a procedure or function exists in a mysql database? and is there any discovery option? like a
show procedures; (e.g. like show tables;)Solution
A generic answer to this type of question is that all MySQL databases include a database called information_schema which includes all the metadata as tables you can just query.
The information you want is in a table called ROUTINES. For example:
The information you want is in a table called ROUTINES. For example:
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_TYPE="PROCEDURE"
AND ROUTINE_SCHEMA="dbname"
;Code Snippets
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_TYPE="PROCEDURE"
AND ROUTINE_SCHEMA="dbname"
;Context
StackExchange Database Administrators Q#567, answer score: 30
Revisions (0)
No revisions yet.