首頁 >資料庫 >mysql教程 >Mysql数据库表名批量改为大写_MySQL

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

WBOY
WBOY原創
2016-06-01 13:30:311848瀏覽

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