Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 执行SQL命令更新表时出错_Mysql_Jakarta Ee - Fatal编程技术网

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

大家好,我正在尝试在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 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脚本和查询