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

WBOY
发布: 2016-06-01 13:30:31
原创
1843 人浏览过

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
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板