Search If A Specific Column is Used in Stored Procedure or Functions – MySQL

INFORMATION SCHEMA (also referred as system catalog) gives you access to database metadata and MySQL server information like the name of a database or table, the data type of a column, and access privileges.

We’ll look at how to search a specific column if it’s utilized in Stored Routines (Functions and Stored Procedures) in this article.

— Searching a column in all Functions and Stored Procedures of a specific database.
SELECT * FROM information_schema.ROUTINES
WHERE ROUTINE_SCHEMA = ‘TestDB’
AND ROUTINE_DEFINITION LIKE ‘%DepartmentID%’;

— Searching a column in all Functions and Stored Procedures from all databases.
SELECT * FROM information_schema.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ‘%DepartmentID%’;

Happy learning!!!

One comment

Leave a Reply