DROP PROCEDURE IF EXISTS `UPPERCASE`;
delimiter ;;
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
;;