开发者

change MySQL field type if field exists

I have the following query:

ALTER TABLE table CHAN开发者_开发百科GE field1 field1 INTEGER

Is there anyway that I can add some sort of if exists to this statement so that MySQL will make sure that field 1 exists before attempting to change its field type?


ALTER TABLE in MySql does not take an IF EXISTS clause.

You can do a

describe table 

or

show columns from table

to get the list of all columns and then check if field1 is present before you do a ALTER TABLE

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜