这个事务代码中的Mysql语法错误?非常令人沮丧

时间:2022-10-20 22:42:37

I have this code for a small transaction. But MYSQL keeps throwing syntax error. I wrote the code below in a .sql file and I run it in mysql using the command 'source filename' but it throws the following error:

我有一个小事务的代码。但是MYSQL不断抛出语法错误。我在.sql文件中编写了下面的代码,并使用命令'source filename'在mysql中运行它,但它抛出以下错误:

ERROR 1064 (42000): 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 'INSERT INTO tab VALUES (1,"A1", 10000,100);
INSERT INTO tab VALUES (2,"A2", 1000' at line 2

Can you find error in my code as shown below?

你能在我的代码中找到错误,如下所示?

DELIMITER **
START TRANSACTION
INSERT INTO tab VALUES (1,"A1", 10000,100);
INSERT INTO tab VALUES (2,"A2", 10000,100);
INSERT INTO tab VALUES (3,"A3", 10000,100);
INSERT INTO tab VALUES (4,"A4", 10000,100);
INSERT INTO tab VALUES (5,"A5", 10000,100);
INSERT INTO tab VALUES (6,"A6", 10000,100);
INSERT INTO tab VALUES (7,"A7", 10000,100);
INSERT INTO tab VALUES (8,"A8", 10000,100);
INSERT INTO tab VALUES (9,"A9", 10000,100);
INSERT INTO tab VALUES (10,"A10", 10000,100);
END TRANSACTION;
DELIMITER ;

I thought that syntax for INSERT might be wrong but when I run only an insert query, it works. I can't find anything wrong in here. I use mysql 5.5.41

我认为INSERT的语法可能是错误的,但是当我只运行一个插入查询时,它可以工作。我在这里找不到任何错误。我使用mysql 5.5.41

1 个解决方案

#1


0  

You are missing a semicolon:

你错过了一个分号:

START TRANSACTION;

#1


0  

You are missing a semicolon:

你错过了一个分号:

START TRANSACTION;