oracle Update comparing Varchar

。_饼干妹妹 提交于 2019-12-11 23:34:33

问题


I have two tables:

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

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?

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);

回答1:


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);


来源:https://stackoverflow.com/questions/33504018/oracle-update-comparing-varchar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!