问题
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