MYSQL modifies the table name to a large-write stored procedure, mysql Stored Procedure

Source: Internet
Author: User

MYSQL modifies the table name to a large-write stored procedure, mysql Stored Procedure

This article will share with you the stored procedure of modifying the table name to uppercase in MYSQL. The specific content is as follows:

1. conditions:
1.1 Mysql settings are case sensitive
2. Execute the following stored procedures:

# Call uppercase ('database name') drop procedure if exists uppercase; create procedure uppercase (IN dbname VARCHAR (200) begin declare done int default 0; DECLARE oldname VARCHAR (200 ); DECLARE cur cursor for select table_name FROM information_schema.TABLES WHERE table_schema = dbname; declare continue handler for not found set done = 1; OPEN cur; repeat fetch cur INTO oldname; SET @ newname = UPPER (oldname); SET @ isNotSame = @ newname <> BINARY oldname; if not done & @ isNotSame then set @ SQL = CONCAT ('rename table '', oldname, ''to '', LOWER (@ newname), '_ tmp''); PREPARE tmpstmt FROM @ SQL; EXECUTE tmpstmt; SET @ SQL = CONCAT ('rename table'', LOWER (@ newname), '_ tmp' to '', @ newname, '''); PREPARE tmpstmt FROM @ SQL; EXECUTE tmpstmt; deallocate prepare tmpstmt; end if; UNTIL done end repeat; CLOSE cur; END

3. Execute the following statement:
Call uppercase ('database name ');

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.