mysql批量插入
有多种方式
其中效率高 要求低的方式 是 把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批量插入的更多相关文章
- Oracle/Mysql批量插入的sql,效率比较高
1.oracle 批量插入: insert into tableName(col1,col2,col3...) select 1,'第一行第一列值','第二列值' from dual union ...
- mysql批量插入简单测试数据
mysql批量插入简单测试数据 # 参考网址: https://www.2cto.com/database/201703/618280.html 1.mysql创建测试表 CREATE TABLE ` ...
- MySQL 批量插入值
MySQL 批量插入值 今天遇到个问题,需要从类似以下语句中的各个小括号[其实也有中括号等]抽取相关字段进行组合[相关规则,此处略去不提],并保存到数据库中,此时如果每次插入一条,会连续进行多次插入, ...
- mybatis + mysql 批量插入、删除、更新
mybatis + mysql 批量插入.删除.更新 Student 表结构 批量插入 public int insertBatchStudent(List<Student> studen ...
- mybatis+mysql批量插入和批量更新、存在及更新
mybatis+mysql批量插入和批量更新 一.批量插入 批量插入数据使用的sql语句是: insert into table (字段一,字段二,字段三) values(xx,xx,xx),(oo, ...
- mybatis oracle mysql 批量插入时的坑爹问题--需谨记
mybatis oracle mysql 批量插入一.oracle的批量插入方式insert into db(id, zgbh, shbzh) select '1', '2', '3' from du ...
- MySQL 批量插入 Update时Replace
建一张试验表如下: 一.批量插入 MySQL的INSERT有一种写法如下: INSERT INTO person VALUES (NULL,'关羽', '2016-04-22 10:00:00'), ...
- MYSQL批量插入数据库实现语句性能分析
假定我们的表结构如下 代码如下 CREATE TABLE example ( example_id INT NOT NULL, name VARCHAR( 50 ) NOT NULL, value ...
- mybatis mysql 批量插入
场景描述: 使用mybatis操作mysql数据库,进行批量插入数据,提高代码质量和执行效率. 环境: mybatis spring mysql java xml配置文件 <insert id ...
- mysql批量插入语句执行失败的话,是部分失败还是全部失败
项目开发中,正好遇到这个问题. 将一批从外部第三方接口获取到的数据存储到本地mysql数据库,假设接口返回的数据类型为A,经过A到B的转换规则转换后, 要插入数据库的数据类型为B.那么在A获取到100 ...
随机推荐
- python写入excel(xlswriter)--生成图表
一.折线图: # -*- coding:utf-8 -*- import xlsxwriter # 创建一个excel workbook = xlsxwriter.Workbook("cha ...
- 每天一个linux命令(17):whereis
1.命令简介 whereis (whereis) 命令用来定位指令的二进制程序.源代码文件和man手册页等相关文件的路径. whereis命令只能用于程序名的搜索,而且 ...
- 并行排序ShearSort ---[MPI , c++]
思想: (1) 对于一个nxm的数组,使用N个work进行处理. (2) 先按行对数组进行升序和降序排序[由左至右],一般奇数序列work升序,偶数序号的work进行降序 (3)再按列对数组进行升序排 ...
- Window 包管理工具: chocolatey
传送门 # 官网 https://chocolatey.org/install # 发生错误看看这个https://yevon-cn.github.io/2017/03/12/install-choc ...
- Kubernetes 1.12公布:Kubelet TLS Bootstrap与Azure虚拟机规模集(VMSS)迎来通用版本号
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/M2l0ZgSsVc7r69eFdTj/article/details/82880341 https: ...
- Mybatis 级联查询时只查出了一条数据
造成这个问题的原因是: 主表和明细表的id字段名相同造成的. 问题的关键在于resultMap中如果不定义类似主键之类的能够区分每一条结果集的字段的话,会引起后面一条数据覆盖前面一条数据的现象.
- idea maven 集成多模块 module
首先第一步创建 顶级项目 也就是父项目 在创面那部中 不管你勾不勾 create from 那个选项 都无所谓,最终创建的项目要全删的 ,只保留pom.xml 父项目结构 接下来 创建子项目 也是 ...
- [转]MySQL中timestamp数据类型的特点
原文地址:https://www.imooc.com/article/16158 在使用MySQL数据库时有很多常见的误解,其中使用int类型来保存日期数据会提高数据读取的效率就是比较常见的一个误解. ...
- SQLSERVER性能调优小技巧
平时做个记录,在工作过程中针对大数据查询的一些小技巧 -----------SELECT------------- 1.必要的冗余字段,减少关联查询 2.关键查询字段必须加索引 否则百万级以上你就别想 ...
- hdoj:2080
夹角有多大II Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...