-- 给task表及子表添加字段
DELIMITER //
drop procedure if exists taskAddFieldPro//
CREATE PROCEDURE taskAddFieldPro()
BEGIN
DECLARE tableName varchar(50) default '';
DECLARE done INT DEFAULT 0;
DECLARE taskCursor CURSOR FOR select table_name from information_schema.tables where table_schema='uc_ipcc_cloud_ai' and table_name like 'tb_ucpaas_task_run%';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN taskCursor;
REPEAT
FETCH taskCursor INTO tableName;
IF not done THEN
set @sql=concat('alter table ',tableName,' add tel_time int(11) DEFAULT NULL COMMENT "通话时长,秒"');
PREPARE stmt from @sql;
execute stmt;
set @sql1=concat('alter table ',tableName,' add hangup_type char(1) DEFAULT NULL COMMENT "挂断方式:0 主动挂断 1 被动挂断"');
PREPARE stmt1 from @sql1;
execute stmt1;
END IF;
UNTIL done END REPEAT;
CLOSE taskCursor;
END
//
DELIMITER;
CALL taskAddFieldPro();
MYSQL存储过程修改表结构 TODO
最新推荐文章于 2023-03-01 18:10:26 发布