当前位置:Gxlcms > 数据库问题 > MySql新增列的时候判断是否存在

MySql新增列的时候判断是否存在

时间:2021-07-01 10:21:17 帮助过:4人阅读

procedure if exists schema_change; delimiter ;;; create procedure schema_change() begin if not exists( select * from information_schema.`COLUMNS` where TABLE_NAME=QYTB_DYAQ and COLUMN_NAME=BDCQYWBSM) then alter table QYTB_DYAQ add BDCQYWBSM CHAR(1); end if; end;; delimiter ;; -- 调用存储过程 call schema_change(); drop procedure if exists schema_change;

我们通过这段代码感觉只要存储过程的内容体就能实现目的,为什么还要创建一个存储过程来处理呢?

因为Mysql不支持直接写入如上内容体的格式。于是只能曲线救国了。

MySql新增列的时候判断是否存在

标签:一个   代码   class   char   end   exists   name   change   sele   

人气教程排行