MYSQL:语法错误:' DELETE'在此位置无效输入

时间:2018-04-07 19:42:28

标签: mysql sql database

这是我第一次尝试进行交易,并且我希望进行交易以从类表中删除所有德国船只,并同时在表格中添加新的美国船只。

START TRANSACTION
-- Delete Germany from classes table
DELETE FROM classes WHERE country = 'Germany';
-- Add new ship for USA into classes table
INSERT INTO `classes` (`class`,`type`,`country`,`numGuns`,`bore`,`displacement`) 
VALUES ('SS Farkas','bb','USA','10','20','36000');
-- Commit the transaction
commit;

我尝试在DELETE FROM语句的开头执行时遇到此语法错误:

  

语法错误:'删除' (删除)在此位置无效输入

2 个答案:

答案 0 :(得分:0)

您遗失;

START TRANSACTION;

-- Delete Germany from classes table
DELETE FROM classes WHERE country = 'Germany';
-- Add new ship for USA into classes table
INSERT INTO `classes` (`class`,`type`,`country`,`numGuns`,`bore`,`displacement`) 
VALUES ('SS Farkas','bb','USA','10','20','36000');
-- Commit the transaction
commit;

答案 1 :(得分:0)

删除查询有效,但您遗失了;

START TRANSACTION应为START TRANSACTION;

更多:https://dev.mysql.com/doc/refman/5.7/en/commit.html