当前位置:网站首页>Batch capitalization of MySQL table names
Batch capitalization of MySQL table names
2022-06-24 20:29:00 【SugarPPig】
DROP PROCEDURE IF EXISTS upperTable;
DELIMITER $
CREATE PROCEDURE upperTable(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 ;
Execute the stored procedure :
upperTable(' Database name ');
边栏推荐
- The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
- The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
- Using dynamic time warping (DTW) to solve the similarity measurement of time series and the similarity identification analysis of pollution concentration in upstream and downstream rivers
- 《梦华录》“超点”,鹅被骂冤吗?
- Why is the executor thread pool framework introduced
- Coinbase将推出首个针对个人投资者的加密衍生产品
- [cann document express issue 05] let you know what operators are
- Open programmable infrastructure (OPI) project, redefining dpu/ipu
- 年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
- unity之模糊背景(带你欣赏女人的朦胧美)
猜你喜欢

Docker installing Oracle

16个优秀业务流程管理工具

使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value

图的基本概念以及相关定义
思源笔记工具栏中的按钮名称变成了 undefined,有人遇到过吗?

JMeter environment deployment

Map跟object 的区别

物聯網?快來看 Arduino 上雲啦

The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022

Bytebase joins Alibaba cloud polardb open source database community
随机推荐
Coinbase will launch the first encryption derivative for individual investors
DX12引擎开发课程进度-这个课程到底讲到哪里了
Information theory of popular science Shannon
《梦华录》“超点”,鹅被骂冤吗?
Using dynamic time warping (DTW) to solve the similarity measurement of time series and the similarity identification analysis of pollution concentration in upstream and downstream rivers
Install the custom module into the system and use find in the independent project_ Package found
Two solutions to the problem of 0xv0000225 unable to start the computer
华为云ModelArts第四次蝉联中国机器学习公有云服务市场第一!
Huawei cloud modelarts has ranked first in China's machine learning public cloud service market for the fourth time!
"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"
物联网?快来看 Arduino 上云啦
Vxlan and MPLS: from data center to Metro Ethernet
Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?
Hutool reads large excel (over 10m) files
Fundamentals of performance testing -- definitions of common terms
Accurate calculation of task progress bar of lol mobile game
First understand redis' data structure - string
情绪识别AI竟「心怀鬼胎」,微软决定封杀它!
C language to realize mine sweeping (simple version)
实现基于Socket自定义的redis简单客户端