This article shares the MySQL stored procedure that modifies the table name to uppercase, as follows
1. Conditions:
1.1 MySQL settings are case sensitive
2. Execute the following stored procedures:
#call uppercase (' Library name ') DROP PROCEDURE IF EXISTS uppercase;
CREATE PROCEDURE Uppercase (in dbname VARCHAR) is 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 does FOUND SET done = 1;
OPEN cur;
REPEAT FETCH cur into oldname;
SET @newname = UPPER (oldname);
SET @isNotSame = @newname <> BINARY oldname;
IF not do && @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 do end REPEAT;
Close cur; End
3. Execute the statement
Call uppercase (' Library name ');
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.