有多种方式

其中效率高 要求低的方式 是 把sql拼接出来 后一次性commit;

eg:

public int insertBatch(List<PeccDetailModel> list) {
return super.insert("com.hshc.web.pec.dao.PeccDetailDao.insertBatch",list);
}
<insert id="insertBatch">

    insert ignore into table_
(
id, pecc_id,
pecc_no,
plate_no,
infomation_code,
pecc_time,
pecc_addr,
pecc_reason,
pecc_amount,
status,
department,
pecc_score,
pecc_code,
violation_code,
archive_no,
phone,
excute_location,
excute_department,
category, late_fees,
basis_punishment,
illegal_entry,
location_id,
pecc_location_code,
location_name,
source_id,
record_type,
handle_time,
parties, version,
create_emp,
create_emp_id,
create_time,
modify_emp_id,
modify_emp,
modify_time,
vin_no,
engine_no,
city_id
)
values
<foreach collection="list" separator="," item="item">
(
#{item.id},
#{item.peccId},
#{item.peccNo},
#{item.plateNo},
#{item.infomationCode},
#{item.peccTime},
#{item.peccAddr},
#{item.peccReason},
#{item.peccAmount},
#{item.status},
#{item.department},
#{item.peccScore},
#{item.peccCode},
#{item.violationCode},
#{item.archiveNo},
#{item.phone},
#{item.excuteLocation},
#{item.excuteDepartment},
#{item.category},
#{item.lateFees},
#{item.basisPunishment},
#{item.illegalEntry},
#{item.locationId},
#{item.peccLocationCode},
#{item.locationName},
#{item.sourceId},
#{item.recordType},
#{item.handleTime},
#{item.parties},
#{item.version},
#{item.createEmp},
#{item.createEmpId},
#{item.createTime},
#{item.modifyEmpId},
#{item.modifyEmp},
#{item.modifyTime},
#{item.vinNo},
#{item.engineNo},
#{item.cityId}
)
</foreach>
</insert>

mysql批量插入的更多相关文章

  1. Oracle/Mysql批量插入的sql,效率比较高

    1.oracle 批量插入: insert into tableName(col1,col2,col3...)    select 1,'第一行第一列值','第二列值' from dual union ...

  2. mysql批量插入简单测试数据

    mysql批量插入简单测试数据 # 参考网址: https://www.2cto.com/database/201703/618280.html 1.mysql创建测试表 CREATE TABLE ` ...

  3. MySQL 批量插入值

    MySQL 批量插入值 今天遇到个问题,需要从类似以下语句中的各个小括号[其实也有中括号等]抽取相关字段进行组合[相关规则,此处略去不提],并保存到数据库中,此时如果每次插入一条,会连续进行多次插入, ...

  4. mybatis + mysql 批量插入、删除、更新

    mybatis + mysql 批量插入.删除.更新 Student 表结构 批量插入 public int insertBatchStudent(List<Student> studen ...

  5. mybatis+mysql批量插入和批量更新、存在及更新

    mybatis+mysql批量插入和批量更新 一.批量插入 批量插入数据使用的sql语句是: insert into table (字段一,字段二,字段三) values(xx,xx,xx),(oo, ...

  6. mybatis oracle mysql 批量插入时的坑爹问题--需谨记

    mybatis oracle mysql 批量插入一.oracle的批量插入方式insert into db(id, zgbh, shbzh) select '1', '2', '3' from du ...

  7. MySQL 批量插入 Update时Replace

    建一张试验表如下: 一.批量插入 MySQL的INSERT有一种写法如下: INSERT INTO person VALUES (NULL,'关羽', '2016-04-22 10:00:00'), ...

  8. MYSQL批量插入数据库实现语句性能分析

    假定我们的表结构如下 代码如下   CREATE TABLE example ( example_id INT NOT NULL, name VARCHAR( 50 ) NOT NULL, value ...

  9. mybatis mysql 批量插入

    场景描述: 使用mybatis操作mysql数据库,进行批量插入数据,提高代码质量和执行效率. 环境: mybatis spring mysql java xml配置文件 <insert id ...

  10. mysql批量插入语句执行失败的话,是部分失败还是全部失败

    项目开发中,正好遇到这个问题. 将一批从外部第三方接口获取到的数据存储到本地mysql数据库,假设接口返回的数据类型为A,经过A到B的转换规则转换后, 要插入数据库的数据类型为B.那么在A获取到100 ...

随机推荐

  1. 【php】php5.0以上,instanceof 用法

    1.instanceof php官网:http://php.net/manual/zh/language.operators.type.php 2.instanceof 用于确定一个 PHP 变量是否 ...

  2. Docker入门 - 003 Docker 实例

    Docker Hello World Docker 允许你在容器内运行应用程序, 使用 docker run 命令来在容器内运行一个应用程序. 输出Hello world runoob@runoob: ...

  3. Linux下通过server-status监控性能

    Linux下通过server-status监控性能 前提:安装好Apache,在opt/路径下 查看Apache的工作模式 可以知道是 prefork.c模式 配置server-status 性能 进 ...

  4. amqp笔记

    1.exchange message的生产者可以将消息发送给exchange,然后由exchange路由到不同的queue中. exchange有4种类型: direct exchange:msg只会 ...

  5. 环境的配置; host 配置地址

    1.环境的配置: C:\Windows\System32\drivers\etc 2.如果没有下载host 切记复制etc的文件,在c盘桌面打开,更改后替换 3.可下载host 和fiddle 4.多 ...

  6. java语言的优缺点

    转载自:https://blog.csdn.net/bingshanyijiao_fkx/article/details/51613954 角度一: 优点:简单.安全.稳定.跨平台 缺点:需要运行环境 ...

  7. Java多线程:多线程基础知识

    一.线程安全性 定义:多个线程之间的操作无论采用何种执行时序或交替方式,都要保证不变性条件不被破坏     “共享”:变量可以由多个线程同时访问:     “可变”:变量的值在其生命周期内可以发生改变 ...

  8. Use OWIN to Self-Host ASP.NET Web API 2 来访问我的webapi

    就是说我们本地的http://localhost:49708/api/test可以通过 这个东西来访问(懒得挂载iis,当然它的强大可不这些,由于测试出了问题 出记录一下) 首先去Nuget包里找到M ...

  9. 1.介绍(introduction)

    这里主要记录一本书的学习过程: 条件独立: 意思是X和Y在given Z的情况下是独立的. 满足P(X,Y|Z) = P(X|Z)*P(Y|Z)以及P(X|Y,Z) = P(X|Z) 条件独立的一些性 ...

  10. winscp的root连接ubuntu“拒绝访问”的解决方法

    转载:https://www.cnblogs.com/weizhxa/p/10098640.html 解决: 1.修改ssh配置文件:sudo vim etc/ssh/sshd_config 在#Pe ...