Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> A question about UPDATE. How smart is oracle

A question about UPDATE. How smart is oracle

From: Ole Hansen <ohahaahr_at_hotmail.com>
Date: 16 May 2005 12:04:22 -0700
Message-ID: <3d05b5c1.0505161104.516eec2d@posting.google.com>


Hi !

A quick question from a danish oracle newbie.

I have 2 tables, and i want to update a field in table t1 with the sum of a field in table t2.

The tables are BIG, so therefore i want the statement to be a effective as posible.

I have made 2 statements, shown below. Which one should i use ?

Statement 1:
UPDATE table1 t1 SET t1.TotalQty = (Select sum(t2.Qty)FROM table2 t2 WHERE t1.itemnumber=t2.itemnumber)

or

Statement 2:
UPDATE table1 t1 SET t1.TotalQty = (Select sum(t2.Qty)FROM table2 t2 WHERE t1.itemnumber=t2.itemnumber) WHERE t1.TotalQty != (Select sum(t2.Qty)FROM table2 t2 WHERE t1.itemnumber=t2.itemnumber)

Will oracle make unnessesary updates if i use statement 1, or will it actually jus update the rows, were t1.TotalQty != (Select sum(t2.Qty)FROM table2 t2 WHERE t1.itemnumber=t2.itemnumber)

Thanks in advance, for any help given to me.

Regards, Ole

By the way - if anyone nows some good webpages, with sql-tutorials, please let me know... Received on Mon May 16 2005 - 14:04:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US