sqlite批量插入的坑,批量只支持500条数据 sqlite executeBatch()

本文深入解析SQLite数据库的批量插入机制,对比Oracle与MySQL的插入方式,介绍SQLite特有的union all批量插入语法,以及如何通过调用JDBC批处理方法实现高效的数据批量加载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SQLite是一个自包含的高可靠性, 嵌入式, 功能齐全公共领域,SQL数据库引擎。

sqlite批量插入操作不能为oracle与mysql的方式进行插入即是insert into values('','','');insert into values('','','');

多个插入语句组合成的sql插入方式。

sqlite支持的批量插入方式为

insert into tablename (col1,col2,col3)  select '','','' union all select '','','' union all select '','','';

多组值之间用 union all 连接。个人觉得这个方式类似,oracle 中 insert into table select col1,col2,...coln from other_table 的方式,只是sqlite中select 来源的值是手动拼接面成的。注意:sqlite 批量插入最大只支持500条数据,即最多只能出现500个select。

通过批量调用 jar包中的addBatch,与executeBatch方法。

              this.getConnection().setAutoCommit(false);
                this.getStatement().addBatch(sql);
                this.getStatement().executeBatch();
                this.getStatement().close();
                this.getConnection().commit();
                this.getConnection().setAutoCommit(true);

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值