Oracle 通过 JDBC 直接加载 INSERT?
是否可以通过 JDBC 在 Oracle 中进行直接加载 INSERT?
我目前使用批量准备好的语句(通过 Spring JDBC),有什么方法可以使这些语句绕过 NOLOGGING 表上的重做日志?
这是 Oracle 11g 的情况。
Is it possible to do direct-load INSERTs in Oracle through JDBC?
I currently use batched prepared statements (through Spring JDBC), is there any way to make these bypass the redo logs on a NOLOGGING table?
This is with Oracle 11g.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
直接路径插入仅适用于
insert into x as select * from y
场景。这可以使用jdbc来完成,没问题。这不能通过插入和值来完成。当数据库处于强制日志记录模式时,也无法执行此操作。大多数时候,当备用数据库连接时,主数据库将处于强制日志记录模式。正如 Gary Myers 提到的,从 11gR2 开始,就有了 APPEND_VALUES 提示。与“旧”附加提示一样,它只能用于批量插入。
我希望这有帮助,
罗纳德.
direct path inserts are only possible in a
insert into x as select * from y
scenario. This can be done using jdbc, no problem. This can not be done with insert and values. This also can not be done when the database in in force logging mode. Most of the times when a standby database in connected, the primary database will be in force logging mode.As Gary Myers mentioned, since 11gR2 there is the APPEND_VALUES hint. As with the 'old' append hint, it should only be used for bulk inserts.
I hope this helps,
Ronald.
11gR2 中引入了一个 APPEND_VALUES 提示,用于使用 INSERT 进行直接路径插入。 ..价值观。
没有 11gR2 实例可用于测试它是否适用于 JDBC 批量插入。不过值得一试。
There is an APPEND_VALUES hint introduced in 11gR2 for direct path inserts with INSERT...VALUES.
Don't have an 11gR2 instance available to test whether it works with JDBC batch inserts. It is worth a try though.
我能够通过 JDBC 批处理将 APPEND_VALUES 提示与 Oracle 12c 一起使用。我验证了通过 Oracle Enterprise Manager 发生的直接路径插入,其中解释计划显示加载为选择
编辑:我不再参与该项目,但我尝试提供更多详细信息:
代码如下:
需要验证是否真正使用了直接路径(表被锁定/同一交易中的常规插入失败/实际执行计划显示加载为选择)
方法
prepareTableForLargeInsert
和repairTableAfterLargeInsert
正在调用存储过程。它们可能会有所帮助:我记得为禁用的 UC 重新创建定制索引存在问题,例如,因为丢失了它们如何分区的信息(全局哈希分区)(使索引无法使用不起作用)
注意:
I was able to use APPEND_VALUES hint with Oracle 12c with JDBC batching. I verified direct path insert happened via Oracle Enterprise manager where explain plan shows Load As Select
edit: I am not on the project anymore but I try to come up with more details:
The code was something like:
One needs to verify whether direct path was really used (table is locked / conventional insert in same tx fails / actual execution plans shows Load As Select)
methods
prepareTableForLargeInsert
andrepairTableAfterLargeInsert
were calling stored procedures. They might be helpful:I recall there were issues with recreating tailored indexes for disabled UC e.g. because of losing the information how they were partitioned (global hash partitioned) (making the indexes just UNUSABLE doesn't work)
Notes:
?
在 JDBC 中不起作用
Does
not work in JDBC ?
使用:
Use: