oracle更新比较Varchar [英] oracle Update comparing Varchar

查看:84
本文介绍了oracle更新比较Varchar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:

OrdHead: Order_no, CustOrd
OrdItem: Item, Order_no, CustOrd

两个表都使用字母数字的Order_No联接..我需要使用Order_no在OrdHead表中使用相同的CustOrd号更新OrdItem的CustOrd(NUMBER)列.

Both the tables are joined using Order_No which is Alphanumeric.. I need to to update CustOrd (NUMBER) column of OrdItem with the same CustOrd number in OrdHead table using Order_no.

做到这一点的最佳方法是什么?我要在表中添加索引吗?

What is the best way to do that ? Do I add any index to the tables?

目前,我使用以下查询来执行此操作,但是它仅花费100,000条记录就花费了很多时间.

Currently I do it with the following query, but its taking alot of time just with 100,000 records.

UPDATE ORDITEM A SET CUSTORD =
(SELECT CUSTORD FROM ORDHEAD b WHERE b.ORDER_NO = a.ORDER_NO);

推荐答案

如果查询有效,则可以使用索引来修复性能:

If your query works, then you can fix the performance with an index:

create index idx_ordhead_order_no_custord on orderhead(order_no, custord);

这篇关于oracle更新比较Varchar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆