如何从MySQL中的变量添加具有默认值的列?

时间:2019-06-12 11:16:13

标签: mysql

我尝试过

SET @branch := 'BRANCH_A';

ALTER TABLE item
ADD COLUMN branch VARCHAR(15) NOT NULL DEFAULT @branch FIRST;

这将返回错误:

SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@branch FIRST' at line 2

这很好用

ALTER TABLE item
ADD COLUMN branch VARCHAR(15) NOT NULL DEFAULT 'BRANCH_A' FIRST;

我哪里出错了?

0 个答案:

没有答案