![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I have made 2 statements, shown below. Which one should i use ? |
#4
| |||
| |||
|
|
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 ? |
#5
| |||
| |||
|
|
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... |
#6
| |||
| |||
|
|
Run EXPLAIN PLAN and/or AUTOTRACE. A DBA where you work will no doubt smile when you ask for help doing this as most DBAs despise developers that don't do this on every SQL statement they write. |
#7
| |||
| |||
|
|
DA Morgan <damorgan (AT) psoug (DOT) org> wrote Run EXPLAIN PLAN and/or AUTOTRACE. A DBA where you work will no doubt smile when you ask for help doing this as most DBAs despise developers that don't do this on every SQL statement they write. Hi ! Unfortunately we don't have an internal DBA in our company. We use an external oracle-consultant. And everytime i have to call him, i have to pay :-) Our oracle database is quite small (20 Gb), and the application using it is Microsoft Business solutions XAL (Formerly known as Navision XAL or Concorde XAL) XAL has its own query language (eXtended Application Language - XAL), so therefore it's not nessesary to have an internal DBA or SQL-programmer. |
|
BUT - sometimes the XAL query language is to slow for our queries, and then we are forced to use SQL. There are also some other limitations in the XAL-language. I have been an XAL-programmer for 10 years, but i am quite new to SQL, so therefore i sometime posts theese newbie-questions. (This should also clear the misunderstanding of me beeing a student, who don't want to do his homework himself. I graduated many years ago :-)) I am not shure how to make an explain plan. I have recently purchased TOAD, but i am not sure, if i can make an explain plan there. |
|
Perhaps someone can help ? Regards, Ole |
#8
| |||
| |||
|
|
DA Morgan <damorgan (AT) psoug (DOT) org> wrote Run EXPLAIN PLAN and/or AUTOTRACE. A DBA where you work will no doubt smile when you ask for help doing this as most DBAs despise developers that don't do this on every SQL statement they write. Hi ! Unfortunately we don't have an internal DBA in our company. We use an external oracle-consultant. And everytime i have to call him, i have to pay :-) |
#9
| |||
| |||
|
|
You contradict yourself. On the one hand you state 'unfortunately' you don't have a DBA, on the other hand you state you don't need him/her. Obviously, the decision not to hire a DBA is pennywise poundfoolish, especially as you are using a third party product to query the database. And what if your database crashes? You are of course right. Luckily i have never experienced a database |
#10
| |||
| |||
|
|
Sybrand Bakker <postbus (AT) sybrandb (DOT) demon.nl> wrote You contradict yourself. On the one hand you state 'unfortunately' you don't have a DBA, on the other hand you state you don't need him/her. Obviously, the decision not to hire a DBA is pennywise poundfoolish, especially as you are using a third party product to query the database. And what if your database crashes? You are of course right. Luckily i have never experienced a database crash, and i hope i newer will. If our database crashes, we have a 4-hours on-site-support agreement. Hopefully a DBA will arrive within 4 hours, and solve the problem. This means, that for 4 hours, our ERP-program will not run, which means no invoicing, no orderprocessing, no pick jobs in the warehouse etc. It will probaly cost us several thousand euros in lost workhours, since we are 500 employees in the company. But our management thinks, that this is an OK solution. So that's the way it is. Regards, Ole |
![]() |
| Thread Tools | |
| Display Modes | |
| |