最新消息: 新版网站上线了!!!

mysql批量插入数据方法

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");

.....

转载请注明:谷谷点程序 » mysql批量插入数据方法