背景:今天在部署sql代码的时候,发现以前一直使用的判断字段存在的方式不起作用了,如下:
在网上找了好久方法,liquibase的资料太少,最后决定使用存储过程去判断,这种方法确实好用。
delimiter //
create procedure add_more_to_logins() begin
if not exists(select * from information_schema.COLUMNS
where table_name = ‘a‘ AND column_name = ‘b‘ and table_schema = database()) THEN
alter table a add `is_mobile` tinyint(1) null after reason;
end if;
END;
//
delimiter ;
本文出自 “Victor的奋斗历程” 博客,请务必保留此出处http://victor2016.blog.51cto.com/6768693/1877797
liquibase判断mysql表字段是否存在
标签:mysql判断字段是否存在
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:http://victor2016.blog.51cto.com/6768693/1877797