Mysql 执行SQL命令更新表时出错
大家好,我正在尝试在Mysql中添加列 下面给出了我的Sql查询Mysql 执行SQL命令更新表时出错,mysql,jakarta-ee,Mysql,Jakarta Ee,大家好,我正在尝试在Mysql中添加列 下面给出了我的Sql查询 CREATE TABLE `mtrans`.`order` ( `id` int(11) NOT NULL AUTO_INCREMENT, `order_date` date NOT NULL, `order_by` varchar(50) NOT NULL, `amount` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARS
CREATE TABLE `mtrans`.`order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_date` date NOT NULL,
`order_by` varchar(50) NOT NULL,
`amount` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
但当我再添加一列时,它会给出类似的错误
下面给出了我的错误日志
Error executing SQL commands to update table.
MySQL Error Nr. 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 'AFTER `amount`' at line 1
您需要在mysql中使用
我假设您已经成功创建了订单表
在现有表中添加列的简单alter table
ALTER TABLE order ADD order_no VARCHAR(10);
查询以在现有列之后添加列
ALTER TABLE order ADD order_no VARCHAR(10) AFTER [Order];
请更新您执行的查询您尝试执行的实际SQL是什么?发布您的表SQL脚本和查询