例如:
ALTER TABLE webstore.Store MODIFY COLUMN (
ShortName VARCHAR(100),
UrlShort VARCHAR(100)
);
但上述方法不起作用。我正在使用 MySql 5.x
最佳答案
ALTER TABLE
可以在一个语句中进行多个表更改,但 MODIFY COLUMN
一次只能处理一列,因此您需要为要更改的每一列指定 MODIFY COLUMN
:
ALTER TABLE webstore.Store
MODIFY COLUMN ShortName VARCHAR(100),
MODIFY COLUMN UrlShort VARCHAR(100);
另外,请注意手册中的此警告:
When you use CHANGE or MODIFY,
column_definition
must include the data type and all attributes that should apply to the new column, other than index attributes such as PRIMARY KEY or UNIQUE. Attributes present in the original definition but not specified for the new definition are not carried forward.
https://stackoverflow.com/questions/3773480/