Database 是否可以在HANA中批量插入?
我想批量插入hana。目前我正在使用Java从结果集中逐行插入。是否有方法一次插入多行?有可能吗?(我不想只导入批量插入)我到处搜索,找不到任何好的答案。非常感谢任何帮助?对于JAVA/JDBC代码,存在所谓的批处理接口。 下面是我用于测试的一个旧示例:Database 是否可以在HANA中批量插入?,database,sap,hana,Database,Sap,Hana,我想批量插入hana。目前我正在使用Java从结果集中逐行插入。是否有方法一次插入多行?有可能吗?(我不想只导入批量插入)我到处搜索,找不到任何好的答案。非常感谢任何帮助?对于JAVA/JDBC代码,存在所谓的批处理接口。 下面是我用于测试的一个旧示例: myDBconn.setAutoCommit(false); PreparedStatement insStmt = myDBconn .prepareStatement("INSERT INTO EFASHION.SHOP_
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();
myDBconn.setAutoCommit(false);
PreparedStatement insStmt=myDBconn
.prepareStatement(“插入EFASHION.SHOP\u事实\u插入\u演示值”
+ " (?, ?, ?, ?, ?, ?, ?, ? )");
对于(int i=1;我请更具体地说明您想要做什么,例如,您想要使用哪种语言或工具。HANA确实支持批量数据加载-这完全取决于您想要使用什么。我使用java从结果集中插入数据。但如果我逐行插入,则会消耗更多时间。有没有办法批量插入?(一次插入多行)@Lars.Br那么如何在HANA中上载数组?我查询并获取结果集中的数组,但如何将其插入HANA,因为insStmt.setArray(9,myArray);
在插入语句看起来类似于插入EFASHION.SHOP\u FACTS\u INS\u DEMO VALUES“+”的地方不起作用(?、?、?、?、?、?、?、?、数组(?)”;
。但是当我手动将类似的插入EFASHION.SHOP\u FACTS\u INS\u DEMO VALUES“+”(?、?、?、?、?、?、?、数组(1,2,3)))时
工作正常。请检查关于此问题的现有讨论:并且:您要求的是批量数据加载,而不是数组插入。请确保在询问此类特定级别时使用正确的术语。谢谢。