mysql 可重复执行添加列
时间:2021-07-01 10:21:17
帮助过:32人阅读
50), IN v_column varchar(
50),IN v_discription varchar(
1000))
begin
declare stmt varchar(2000);
declare v_flag int;
select count(*) into v_flag
from information_schema.columns
where table_schema = (
select DATABASE()) and table_name = v_table and column_name =
v_column;
if(v_flag=
0)
then
set @sqlstr = concat(
‘ALTER TABLE `‘,v_table,
‘` ADD COLUMN `‘,v_column,
‘` ‘,v_discription);
prepare stmt from @sqlstr;
execute stmt;
end if;
commit;
end ;
调用:
call add_column_if(‘xxx‘,‘xxx‘,‘xxx‘);
mysql 可重复执行添加列
标签:调用 format arch proc class cut xxx ble concat