DELIMITER //
DROP PROCEDURE IF EXISTS addColumnPro;
CREATE PROCEDURE addColumnPro(
IN tab varchar(200),
IN colu varchar(200),
IN sqlStr varchar(200))
BEGIN
set @sql = CONCAT('ALTER TABLE ',tab,' ADD COLUMN ',colu, ' ', sqlStr);
IF NOT EXISTS (SELECT * FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = tab AND column_name = colu) THEN
PREPARE stmt FROM @sql;
EXECUTE stmt ;
deallocate prepare stmt;
END IF;
END //
DELIMITER ;
CALL addColumnPro('suc_task_hist', 'MODIFY_TIME_ACC', "varchar(40) DEFAULT NULL COMMENT '精确时间' AFTER `MODIFY_TIME`");