当前位置:网站首页>MYSQL分表DDL操作(存储过程)
MYSQL分表DDL操作(存储过程)
2022-07-26 22:39:00 【everyD_struggle】
思路是获取数据的表名,然后拿到表名进行修改。
drop procedure if exists useCursor;
CREATE PROCEDURE useCursor()
BEGIN
DECLARE oneAddr varchar(36) default '';
DECLARE allAddr varchar(40) default '';
DECLARE done INT DEFAULT 0;
DECLARE curl CURSOR FOR select table_name from information_schema.tables where table_schema='数据库' and table_name like '表民_%';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN curl;
REPEAT
FETCH curl INTO oneAddr;
IF not done THEN
set @sql=concat('alter table ',oneAddr," add 字段名 VARCHAR(32) NOT NUll DEFAULT '' COMMENT 'xxx'; ");
PREPARE stmt from @sql;
execute stmt;
END IF;
UNTIL done END REPEAT;
select allAddr;
CLOSE curl;
END;
call useCursor();
边栏推荐
猜你喜欢
随机推荐
[b01lers2020]Welcome to Earth
[SQL注入] 扩展注入手法
Install redis-7.0.4 in Linux system
Promise基本用法 20211130
DOM day_01(7.7) dom的介绍和核心操作
JSCORE day_01(6.30) RegExp 、 Function
【4.1 质数及线性筛】
postman的使用
Apply with new, delete and malloc, free to free the heap space
[4.9 detailed explanation of inclusion exclusion principle]
【2. Tmux 操作】
The use of C language static can flexibly change the life cycle and make you write code like a duck to water
【Codeforces Round #808 (Div 2.) A·B·C】
2022.7.13
BUUCTF-随便注、Exec、EasySQL、Secret File
[4.4 detailed explanation of fast power and inverse element of fast power]
8_ Polynomial regression and model generalization
5_ Linear regression
啊啊啊啊啊啊啊a
[CTF 真题] 2018-网鼎杯-Web-Unfinish
![[SQL注入] 报错注入](/img/89/4809d427e307574cf73af668be3698.png)



![[HFCTF2020]EasyLogin](/img/23/91912865a01180ee191a513be22c03.png)

![[WUSTCTF2020]CV Maker](/img/64/06023938e83acc832f06733b6c4d63.png)
