2012-07-03 33 views
-1

嗨,我想在Mysql中添加列。執行SQL命令更新表時出錯

我的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 
+0

請更新您執行的查詢 – Prathap

+0

您嘗試執行的實際SQL是什麼? – Blorgbeard

+0

發佈你的表sql腳本和查詢 –

回答

2

我的錯誤日誌中給出你需要MySQL使用alter table

我假設你已經成功創建了order table

簡單的alter table在現有表中添加列。

ALTER TABLE order ADD order_no VARCHAR(10); 

查詢在現有列之後添加列。

ALTER TABLE order ADD order_no VARCHAR(10) AFTER [Order];