是否可以在 HANA 中批量插入?

Is it possible bulk insert in HANA?

我想通过 bulk.Currently 插入 hana 我正在使用 Java 从结果中逐行插入 set.Is 有办法一次插入多行吗?有可能吗? (我不希望仅导入批量插入)我搜索了所有内容,但找不到任何好的 answer.Any 感谢帮助?

对于JAVA/JDBC代码,存在so-called批处理接口。 这是我用于测试的旧示例:

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 数据类型(既不支持单个准备好的语句也不支持批处理)- 以防万一您想要这样做...