Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2015 August Find any text into Stored Procedure and Function of MySQL

Find any text into Stored Procedure and Function of MySQL

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In this post, I am sharing a script to find any text in Stored Procedure and Function of MySQL.

Many times we need to find any object name, column name or comment text in MySQL Routines.

Below is a script to achieve this:

1
2
3
4
5
6
7
SELECT
Routine_Schema
,Routine_Name
,Routine_Type
FROM information_schema.routines
WHERE routines.routine_definition LIKE '%Any_Text%'
AND Routine_Schema = 'db_Name'
Aug 14, 2015Anvesh Patel
Determine free and occupied size of Tables and Database into MySQLFind Table Dependency in MySQL
Comments: 1
  1. Osvaldo
    August 25, 2019 at 5:31 am

    CREATE DEFINER=`root`@`localhost` PROCEDURE `dependencias`()
    NO SQL
    BLOCK1:BEGIN

    DECLARE bas, c1 VARCHAR(50);
    DECLARE fin int DEFAULT FALSE;
    DECLARE cur1 CURSOR FOR SELECT specific_name from information_schema.routines where routine_schema= bas;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET fin = TRUE;

    SET bas=’bayes’;

    DROP TABLE IF EXISTS dependencias;
    CREATE TABLE dependencias (a varchar(50), b varchar(50));
    OPEN cur1;
    rulo1: LOOP
    FETCH cur1 INTO c1;
    IF fin THEN
    LEAVE rulo1;
    END IF;
    BLOCK2: BEGIN
    DECLARE can int;
    DECLARE c2,cad varchar(50);
    DECLARE fin int DEFAULT FALSE;
    DECLARE cur2 CURSOR FOR SELECT specific_name from information_schema.routines where routine_schema= bas;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET fin = TRUE;
    OPEN cur2;
    rulo2: LOOP
    FETCH cur2 INTO c2;
    IF fin THEN
    LEAVE rulo2;
    END IF;
    SET cad=CONCAT (‘%’,c2,'(%’);
    SET can=(SELECT COUNT(*) FROM information_schema.routines WHERE Routine_Name = c1 AND routines.routine_definition LIKE cad AND Routine_Schema = bas);
    IF c1!=c2 AND can>0 THEN
    INSERT INTO `dependencias` values (c1,c2);
    END IF;
    END LOOP rulo2;
    CLOSE cur2;
    END BLOCK2;
    END LOOP rulo1;
    CLOSE cur1;
    END BLOCK1

Anvesh Patel
Anvesh Patel

Database Engineer

August 14, 2015 MySQL, MySQL DBA ScriptAnvesh Patel, database, database research and development, MySQL, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....