mysql批量插入数据方法

时间:2021-03-15 00:41:00

insert插入多条数据有二种方法一种是写多条insert语句用";"号分割每条sql,一种是insert本身的多个value


1,写多条insert用";"分割
这个很简单,;号是mysql执行sql的结束符,写多个insert用;号割就是让mysql执行多次而已.比如:
insert into table (field1,field2,field3) value ('a',"b","c");
insert into table (field1,field2,field3) value ('a',"b","c");
insert into table (field1,field2,field3) value ('a',"b","c");
insert into table (field1,field2,field3) value ('a',"b","c");
insert into table (field1,field2,field3) value ('a',"b","c");


2,在insert中写多个value
INSERT INTO table (field1,field2,field3) VALUES ('a',"b","c"),('a',"b","c"),('a',"b","c");