可重复执行的SQL alter语句

-- 修改通知邮件title字段
DROP PROCEDURE IF EXISTS `MODIFY_TITLE_COLUMN_IN_NOTICE_MAIL`;
DELIMITER //
CREATE PROCEDURE `MODIFY_TITLE_COLUMN_IN_NOTICE_MAIL`()
BEGIN
  DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
  IF EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE()  AND table_name = 't_notice_mail' AND column_name ='title')
  THEN
    UPDATE t_notice_mail SET title=NULL;
    ALTER TABLE `t_notice_mail` CHANGE title title varchar(64) COMMENT 'mail title';
  END IF;
END //
DELIMITER ;
CALL `MODIFY_TITLE_COLUMN_IN_NOTICE_MAIL`();
DROP PROCEDURE `MODIFY_TITLE_COLUMN_IN_NOTICE_MAIL`;

 

可重复执行的SQL alter语句可重复执行的SQL alter语句 sjhuangx 发布了98 篇原创文章 · 获赞 83 · 访问量 44万+ 私信 关注
上一篇:Configuring the SF 7.4.1 Oracle RAC cluster随笔


下一篇:修改浏览器请求头插件Modify Headers