香港服务器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(‘数据库名‘);