我想通过批量插入到hana中。目前我使用Java从结果集中逐行插入。是否有一种方法可以一次插入多行?有可能吗? (我不想只进口批量插入)我搜遍了,找不到任何好的答案。任何帮助表示赞赏?可以批量插入HANA吗?
回答
对于JAVA/JDBC代码,存在所谓的批处理接口。 下面是我用于测试的老例子:
myDBconn.setAutoCommit(false);
PreparedStatement insStmt = myDBconn
.prepareStatement("INSERT INTO EFASHION.SHOP_FACTS_INS_DEMO VALUES"
+ " (?, ?, ?, ?, ?, ?, ?, ? )");
for (int i = 1; i <= LOOPCNT; i++) {
myfacts.createNewFact(); // create a JAVA object with new data
// prepare the new data for the batch
// note that this is a typed assignment.
insStmt.setInt(1, i);
insStmt.setInt(2, myfacts.article_id);
insStmt.setInt(3, myfacts.color_code);
insStmt.setInt(4, myfacts.week_id);
insStmt.setInt(5, myfacts.shop_id);
insStmt.setDouble(6, myfacts.margin);
insStmt.setDouble(7, myfacts.amount_sold);
insStmt.setInt(8, myfacts.quantity_sold);
// add the new data to the batch
insStmt.addBatch();
// limit the batch size, to prevent client side out of memory errors.
// but DON'T commit yet!
// Remember the data in the current batch is kept in client
// memory as long as we don't send it to the HANA server
if (i % BATCHSIZE == 0) {
// executeBatch returns the number of affected rows.
// if we want to use this in the application we just keep adding this up
affectedRows += insStmt.executeBatch();
}
}
// the final batch execution for whatever remained in the
// last batch
affectedRows += insStmt.executeBatch();
// finally commit
myDBconn.commit();
所有这一切在JDBC实况文件记录,以便它不应该是遵循这一问题。
备注:ARRAY数据类型不支持(无论单准备好的发言,也不是批) - 只是这是你想要做什么情况下...
@ Lars.Br然后如何在HANA中上传数组?我查询并获取结果集中的数组,但如何将它插入到HANA,因为'insStmt.setArray(9,myArray);'在我的插入片段看起来像llike时无效'INSERT INTO EFASHION.SHOP_FACTS_INS_DEMO VALUES“ +” (?,?,?,?,?,?,?,?,?,ARRAY(?))“);'但是当我手动插入像'INSERT INTO EFASHION.SHOP_FACTS_INS_DEMO VALUES” + ,?,?,?,?,?,ARRAY(1,2,3))“);'工作正常。 – RKR
请检查现有的讨论:http://stackoverflow.com/questions/40102034/import-array-type-into-hana/40378906#40378906和http://stackoverflow.com/questions/41338263/upload-an -array-in-hana/41353326#41353326 –
另外:你要求BULK数据加载,而不是ARRAY插入。请在这样的特定级别上进行询问时,请务必使用正确的术语。谢谢。 –
- 1. Doctrine DBAL可以批量插入吗?
- 2. 是否可以创建批量插入?
- 3. Hibernate批量插入数据,可以停止吗?
- 4. 我可以从批量插入中检索lastInsertId吗?
- 5. 是否可以在Linq 2 Sql中批量或批量插入?
- 6. 批量/批量插入R
- 7. 批量插入
- 8. 批量插入
- 9. 我可以批量分配变量吗?
- 10. php bindParam()加速批量插入吗?
- 11. Bigtable批量插入
- 12. HQL批量插入
- 13. Sql批量插入
- 14. Laravel批量插入
- 15. kohana批量插入
- 16. 批量插入Cassandra
- 17. Grails批量插入
- 18. 批量插入行
- 19. SQLite3:批量插入?
- 20. 批量插入表
- 21. 批量SQL插入
- 22. oracle批量插入
- 23. VB.net批量插入
- 24. Scrapy批量插入
- 25. mysql批量插入
- 26. SubSonic批量插入
- 27. MySQL批量插入
- 28. 批量插入Neo4j
- 29. AsyncQueryHandler批量插入
- 30. TADOTable - 可以插入吗?
请上正是你想做的事更具体,例如您想要使用哪种语言或工具。 HANA确实支持批量数据加载 - 这一切都取决于您想要使用的内容。 –
我使用java从结果集中插入数据。但是如果我逐行插入它会消耗更多时间。是否有一种方法可以批量插入? (一次插入多行) – RKR