Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果数据库模式版本低于某个值,如何有条件地将列添加到 MySQL 表?这个问题假设我知道足够创建一个_Schema表,但不知道足够实际使用它。
_Schema
我无效的起始代码如下所示:
SELECT @version = `Version` FROM `_Schema`; IF version <= 2 THEN ALTER TABLE `TheTable` ADD `TheNewColumn` smallint(5) unsigned not null; END IF;