drop 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不支持直接寫入如上內容體的格式。於是只能曲線救國了。
