- SQL脚本
select * from users;
- 方式一:
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
insert into users(name, age, course_id) VALUES("test",1, "0");
- 方式二:
insert into users(name, age, course_id) VALUES("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0")
- 时间损耗
在插入上面24条数据的时候发现两者的执行效率相差比较大(近10倍的)
方式一:
方式二:
-
扩展:
那么jdbc中的批处理的内部实现是不是采用方式二的形式来实现呢?感兴趣的朋友可以查看下该部分的源码...