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");
PS:以前用的第一种方法。当插入成千上万条时很慢,今天用第二种方法很快很快。