不要为此使用以下查询-
insert into yourTableName values(yourValue1,yourValue2,...N); insert into yourTableName values(yourValue1,yourValue2,...N); insert into yourTableName values(yourValue1,yourValue2,...N); . . . N
您可以使用以下查询作为在单个查询中插入多个值的最快方法-
insert into yourTableName values(yourValue1,yourValue2,...N),(yourValue1,yourValue2,...N), (yourValue1,yourValue2,...N),...................N;
让我们首先创建一个表-
create table DemoTable1466 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int -> );
使用插入命令在表中插入一些记录-
insert into DemoTable1466(Name,Age) values('Chris',25),('David',29),('Mike',32); Records: 3 Duplicates: 0 Warnings: 0
使用select语句显示表中的所有记录-
select * from DemoTable1466;
这将产生以下输出-
+----+-------+------+ | Id | Name | Age | +----+-------+------+ | 1 | Chris | 25 | | 2 | David | 29 | | 3 | Mike | 32 | +----+-------+------+ 3 rows in set (0.00 sec)