当前位置:网站首页>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 ');
边栏推荐
- Compressed list of redis data structures
- Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
- 【CANN文档速递04期】揭秘昇腾CANN算子开发
- 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
- C語言實現掃雷(簡易版)
- The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
- C langage pour le déminage (version simplifiée)
- unity实战之lol技能释放范围
- 科技抗疫: 运营商网络洞察和实践白皮书 | 云享书库NO.20推荐
- Openstack actual installation and deployment tutorial, openstack installation tutorial
猜你喜欢
思源笔记工具栏中的按钮名称变成了 undefined,有人遇到过吗?

Teach you how to view the number of connected people on WiFi in detail how to view the number of connected people on WiFi

大一女生废话编程爆火!懂不懂编程的看完都拴Q了

二叉树的基本性质与遍历

Dongyuhui is not enough to bring goods to "rescue" live broadcast

Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year

Bytebase 加入阿裏雲 PolarDB 開源數據庫社區

Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1

Bytebase 加入阿里云 PolarDB 开源数据库社区

实现基于Socket自定义的redis简单客户端
随机推荐
华为云ModelArts第四次蝉联中国机器学习公有云服务市场第一!
[cann document express issue 04] unveiling the development of shengteng cann operator
Instruction rearrangement concept
[cann document express issue 06] first knowledge of tbe DSL operator development
The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"
VXLAN 与 MPLS:从数据中心到城域以太网
"Super point" in "Meng Hua Lu", is the goose wronged?
Openvino2022 dev tools installation and use
开放可编程基础设施(OPI)项目,重新定义DPU/IPU
Two solutions to the problem of 0xv0000225 unable to start the computer
You can capture fingerprints with a mobile camera?! Accuracy comparable to signature and monogram, expert: you are aggravating discrimination
Basic operation of sequence table
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
【Go語言刷題篇】Go從0到入門4:切片的高級用法、初級複習與Map入門學習
Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?
物聯網?快來看 Arduino 上雲啦
IP address to integer
Huawei cloud modelarts has ranked first in China's machine learning public cloud service market for the fourth time!
Coinbase will launch the first encryption derivative for individual investors