mysql数据库名称怎么变为大写
在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('数据库名');
声明:本站所有作品(图文、音视频)均由用户自行上传分享,或互联网相关知识整合,仅供网友学习交流,若您的权利被侵害,请联系 管理员 删除。
本文链接:http://news.ew35.com/