Sp_object MYSQL obtains the content of the specified object and Definition Statement in the current instance.

Source: Internet
Author: User

Sp_object MYSQL obtains the content of the specified object and Definition Statement in the current instance [SQL] DELIMITER $ USE 'test' $ DROP PROCEDURE IF EXISTS 'SP _ object' $ CREATE PROCEDURE 'SP _ object '(p_OBJECTNAME VARCHAR (255 ), p_DBNAME VARCHAR (255) BEGIN/* by Chen enhui CALL example: CALL sp_object ('updatefactadgroupdailyusagebyhourly ',''); */-- Process and function SELECT 'type' AS _ type, db as dbname, 'name' as objectname, body as definition from mysql. proc a WHERE db like concat (p_DBNAME, '%') AND 'name' like concat (p_OBJECTNAME, '% ') -- AND 'type' = 'Procedure '-- table union all select 'table' AS _ type, TABLE_SCHEMA, TABLE_NAME, ''as definition from information_schema.TABLES a WHERE TABLE_SCHEMA like concat (p_DBNAME, '%') AND table_name like concat (p_OBJECTNAME, '%') -- trigger union all select 'trigger' AS _ TYPE, TRIGGER_SCHEMA as dbname, TRIGGER_NAME, ACTION_STATEMENT as definition from information_schema. 'trigger' a WHERE TRIGGER_SCHEMA like concat (p_DBNAME, '%') AND TRIGGER_NAME like concat (p_OBJECTNAME, '%') -- view union all select 'view' AS _ TYPE, TABLE_SCHEMA as dbname, TABLE_NAME AS 'viewname', VIEW_DEFINITION as definition from information_schema. 'Views 'a WHERE TABLE_SCHEMA like concat (p_DBNAME, '%') AND TABLE_NAME like concat (p_OBJECTNAME, '%') order by _ TYPE, DBNAME; END $ DELIMITER;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.