current position:Home>I want to insert a large amount of test data into the database, but the statement always reports an error. I don't know where the error is

I want to insert a large amount of test data into the database, but the statement always reports an error. I don't know where the error is

2022-01-27 02:23:44 CSDN Q & A

BEGIN
DECLARE i INT DEFAULT 1;
WHILE i<11150
DO
insert into goods (id,name,price) values (i,CONCAT(i,'.jpg'),i);
SET i=i+1;
END WHILE ;
commit;
END

img

The database is 8.0, Is the database version too high




Refer to the answer 1:
delimiter $CREATE PROCEDURE p8 () BEGINDECLARE i INT DEFAULT 1;WHILE i<11150DOinsert into goods (id,name,price) values (i,CONCAT(i,'.jpg'),i);SET i=i+1;END WHILE ;commit;END; $



Refer to the answer 2:



Refer to the answer 3:

A separate begin,end It's not allowed ,begin end Only in stored procedures , function , The trigger can only be written in it




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270223424470.html

Random recommended