在mysql中將數據庫名稱修改為大寫的方法
1.首先,在命令提示符窗口中,使用命令“net start mysql”啟動mysql;
2.mysql啟動后,繼續使用命令“mysql -hlocalhost -uroot -p”,進入mysql控制臺;
3.進入mysql控制臺后,在控制臺中執行以下存儲過程;
DELIMITER //
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
DELIMITER ;
4.最后,存儲過程執行后,調用對應的數據庫名稱即可完成修改;
call uppercase('數據庫名');