Oracle 文档清楚地说明了这一点:
If you are performing an INSERT with the VALUES clause, specify the APPEND_VALUES hint in
each INSERT statement immediately after the INSERT keyword. Direct-path INSERT with the VALUES
clause is best used when there are hundreds of thousands or millions of rows to load. The
typical usage scenario is for array inserts using OCI. Another usage scenario might be inserts in a FORALL statement in PL/SQL
.
所以回答你的问题是 APPEND_VALUES 提示。我可以在您的帖子中看到您已经尝试过,但无法弄清楚您遇到了什么问题。
此外,您帖子中的此断言也不正确“据我了解,直接路径插入仅支持子查询语法,而不支持 VALUES 子句。” Oracle 文档给出了这个例子:
以下 PL/SQL 代码片段是使用 APPEND_VALUES 提示的示例:
FORALL i IN 1..numrecords
INSERT /*+ APPEND_VALUES */ INTO orderdata
VALUES(ordernum(i), custid(i), orderdate(i),shipmode(i), paymentid(i));
COMMIT;
oracle 文档链接: http: //docs.oracle.com/cd/E11882_01/server.112/e25494/tables004.htm#i1009100
示例代码:
dbConnection.setAutoCommit(false);//commit trasaction manually
String insertTableSQL = "INSERT /*+ APPEND_VALUES */ INTO DBUSER"
+ "(USER_ID, USERNAME, CREATED_BY, CREATED_DATE) VALUES"
+ "(?,?,?,?)";
PreparedStatement = dbConnection.prepareStatement(insertTableSQL);
preparedStatement.setInt(1, 101);
preparedStatement.setString(2, "test1");
preparedStatement.setString(3, "system");
preparedStatement.setTimestamp(4, getCurrentTimeStamp());
preparedStatement.addBatch();
preparedStatement.setInt(1, 102);
preparedStatement.setString(2, "test2");
preparedStatement.setString(3, "system");
preparedStatement.setTimestamp(4, getCurrentTimeStamp());
preparedStatement.addBatch();
preparedStatement.executeBatch();
dbConnection.commit();