甲骨文 |与其他表比较值后更新大表
我有两张大桌子。我们将它们称为 ITEM
表(1807236 条记录)和 ITEM_PROD_DUMP
表(796369 条记录)。 我需要使用主键 (SYS_ITEM_ID
) 匹配。
我已经编写了一个查询来执行此操作,它有效,但仅适用于少数记录。对于这些大量的记录,它只是继续运行。
谁能帮我写一个正确且最佳的查询。
我写的查询:
update item i set i.total_volume_amount = (select ipd.total_volume_amount
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id),
i.total_volume_uom = (select ipd.total_volume_uom
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id)
where exists (select ipd.total_volume_amount
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id);
I have two huge tables. Let's call them as ITEM
table (1807236 records) and ITEM_PROD_DUMP
table (796369 records).
I need to update two columns (total_volume_amount, total_volume_uom
) from ITEM
table with the values of second table ITEM_PROD_DUMP
where their primary key (SYS_ITEM_ID
) matches.
I have written a query to do so, it works but only for handful records. For these huge number of records, it just keeps on running.
Can anyone please help me to write a correct and optimal query.
Query I have written:
update item i set i.total_volume_amount = (select ipd.total_volume_amount
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id),
i.total_volume_uom = (select ipd.total_volume_uom
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id)
where exists (select ipd.total_volume_amount
from item_prod_dump ipd
where i.sys_item_id = ipd.sys_item_id);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 MERGE 语句。纯粹而简单。 180 万条记录并不是一个“巨大”的记录数。
Use a
MERGE
statement. Pure and simple. 1.8 million records is not a "huge" number of records.