欢迎投稿

今日深度:

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

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


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

www.htsjk.Com true http://www.htsjk.com/SQLite/26819.html NewsArticle sqlite批量插入的坑,批量只支持500条数据 sqlite executeBatch(),sqliteexecutebatch SQLite是一个自包含的,高可靠性, 嵌入式, 功能齐全,公共领域,SQL数据库引擎。 sqlite批量插入操作不能为...
相关文章
    暂无相关文章
评论暂时关闭