DEV Community

Cover image for MariaDB Quick-tip #7 - Find stored procedure
Allan Simonsen
Allan Simonsen

Posted on

3 1

MariaDB Quick-tip #7 - Find stored procedure

MariaDB tips and tricks

This is part of a series of quick tips and tricks I have accumulated over the year, that I think can be useful for others.
If you have similar short tips and tricks please leave a comment.

Find stored procedure

When working on large databases there can in some projects be hundreds or even thousands of stored procedures, so if your task is to find all stored procedures that query a specific table then finding it could be quite a headache.
This query below has helped me many times and I hope it will help you too.

SELECT r.ROUTINE_SCHEMA  as "Database",
       r.ROUTINE_NAME  
  FROM information_schema.routines r
 WHERE r.ROUTINE_TYPE  = 'PROCEDURE'
   AND r.ROUTINE_DEFINITION LIKE '%departments%'
 ORDER BY r.ROUTINE_SCHEMA ASC,
       r.ROUTINE_NAME ASC;
Enter fullscreen mode Exit fullscreen mode

DBeaver screenshot

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more