首页 >数据库 >mysql教程 >Mysql数据库表名批量改为大写_MySQL

Mysql数据库表名批量改为大写_MySQL

WBOY
WBOY原创
2016-06-01 13:30:311845浏览

bitsCN.com

Mysql数据库表名批量改为大写

 

[sql] 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);     #IF newname equals to oldname, do nothing;   #select &#39;a&#39; <> &#39;A&#39;; -> 0   #select &#39;a&#39; <> BINARY &#39;A&#39;; -> 1   SET @isNotSame = @newname <> BINARY oldname;     IF NOT done && @isNotSame THEN     SET @SQL = CONCAT(&#39;rename table &#39;,oldname,&#39; to &#39;,@newname);     PREPARE tmpstmt FROM @SQL;     EXECUTE tmpstmt;     DEALLOCATE PREPARE tmpstmt;     END IF;     UNTIL done END REPEAT;     CLOSE cur;     END //     DELIMITER ;   #调用存储过程  #call uppercase(&#39;数据库名&#39;);  #  

 


bitsCN.com
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn