The single update statement to improve performance
Hello
I have a table as shown below and you have written plsql statement, as shown below.
Collar collar collar collar collar E collar F D C B A
NULL NULL NULL NULL 124 124
NULL NULL NULL NULL 235 235
NULL NULL NULL NULL 24556 24556
NULL NULL NULL NULL 45645 45645
NULL NULL NULL NULL 34255 34255
If the Col is not null then
Update tableA
set Col = Col F A;
Otherwise, if the Col B is not null then
Update tableA
game F Col = Col B;
Otherwise, if E Col is not null then
Update tableA
game F Col = Col E;
Otherwise, if the Col D is not null then
Update tableA
game F Col = Col D;
Otherwise, if the Col C is not null then
Update tableA
game F Col = Col C;
Can combine us these if statements in a unique single update statement.
Thank you
Khan
Yes to COALESCE. If you could share create table statement with insert sample instructions will make it much easier for others to test and help you.
for example
update testcoal set colf = coalesce(cola,colb,cole,cold,colc)
Tags: Database
Similar Questions
-
I have 20 or more update like statement below, I am trying to get this single
update of the declaration to facilitate the task, can someone help me pls?
Update Product Set sku_id = (Select sku_id From Product_base Where Product_Code ='WWT204') Where sku_id = (Select sku_id From Product_base Where Product_Code ='9HRC04'); Update Product Set sku_id = (Select sku_id From Product_base Where Product_Code ='WWT205') Where sku_id = (Select sku_id From Product_base Where Product_Code ='9HRC05'); Update Product Set sku_id = (Select sku_id From Product_base Where Product_Code ='WWT206') Where sku_id = (Select sku_id From Product_base Where Product_Code ='9HRC06'); etc... etc..
In general, it can't be since it is possible sku_id update of the first UPDATE will be updated second or third or... UPDATE. Assuming that each UPDATE assigns a unique set of sku_id:
update product p set sku_id = ( select ( select sku_id from product_base pb2 where product_code = case pb1.product_base when '9HRC04' then 'WWT204' when '9HRC05' then 'WWT205' when '9HRC06' then 'WWT206' end ) from product_base pb1 where pb1.sku_id = p.sku_id and product_code in ('9HRC04','9HRC05','9HRC06') ) where sku_id in ( select sku_id from product_base where product_code in ('9HRC04','9HRC05','9HRC06') );
SY.
-
How to convert the next update of FORALL to run the SQL UPDATE statement
I have a FORALL loop for updating a table. It takes too much time. I want to rewrite the code to a direct sql UPDATE. Also of other tips or tricks that can help to run the fastest proc?
Record count: -.CURSOR cur_bst_tm IS SELECT listagg(tm, ' ') WITHIN GROUP(ORDER BY con_addr_id) best_time, con_addr_id FROM (select Trim(Upper(con_addr_id)) con_addr_id, '&' ||decode(Initcap(start_day), 'Monday', 'm', 'Tuesday', 'tu', 'Wednesday', 'w', 'Thursday', 'th', 'Friday', 'f', Initcap(start_day)) ||'=' ||trunc(( ( TO_DATE(start_tm,'HH12:MI:SS PM') - trunc(TO_DATE(start_tm,'HH12:MI:SS PM')) ) * 24 * 60 )) ||',' ||trunc(( ( TO_DATE(end_tm,'HH12:MI:SS PM') - trunc(TO_DATE(end_tm,'HH12:MI:SS PM')) ) * 24 * 60 )) tm FROM (SELECT DISTINCT * FROM ODS_IDL_EDGE_OFFC_BST_TM) WHERE con_addr_id is not null) GROUP BY con_addr_id ORDER BY con_addr_id; TYPE ARRAY IS TABLE OF cur_bst_tm%ROWTYPE; l_data ARRAY; BEGIN OPEN cur_bst_tm; LOOP FETCH cur_bst_tm BULK COLLECT INTO l_data LIMIT 1000; FORALL i IN 1..l_data.COUNT UPDATE ODS_CONTACTS_ADDR tgt SET best_times = l_data(i).best_time, ODW_UPD_BY = 'IDL - MASS MARKET', ODW_UPD_DT = SYSDATE, ODW_UPD_BATCH_ID = '0' WHERE Upper(edge_id) = l_data(i).con_addr_id AND EXISTS (SELECT 1 FROM ods_idl_edge_cont_xref src WHERE tgt.contacts_odw_id = src.contacts_odw_id AND src.pc_flg='Y') ; EXIT WHEN cur_bst_tm%NOTFOUND; END LOOP; CLOSE cur_bst_tm;
Select count (*) from
ODS_IDL_EDGE_OFFC_BST_TM;
140 000
SELECT count (*)
Ods_idl_edge_cont_xref SRC
WHERE src.pc_flg = 'Y';
118 000
SELECT count (*)
OF ODS_CONTACTS_ADDR;
671 925
Version of database 11g.
Execution plan for update:
Operation object name lines cost/output PStart PStop object node bytes
Mode of UPDATE STATEMENT Optimizer = ALL_ROWS 6 K 8120
UPDATE ODW_OWN2. ODS_CONTACTS_ADDR
SEMI 6 K 256 K 8120 HASH JOIN
TABLE ACCESS FULL ODW_OWN2. ODS_CONTACTS_ADDR 6 K 203 K 7181
TABLE ACCESS FULL ODW_OWN2. ODS_IDL_EDGE_CONT_XREF K 118 922 K 938
Edited by: user10566312 May 14, 2012 01:07
-
I want the single update query without using the function.
I want to update sells_table selling_code field with product_code date product table max.
In the product table, there are several product_code date wise.
I did with below charly with the use of the service, but we can do in the query what a single update
without using the function.
UPDATE sells_table
SET selling_code = MAXDATEPRODUCT (ctd_vpk_product_code)
WHERE NVL(update_product_flag,0) = 0;
(P_product IN VARCHAR2) RETURN of HVL.maxdateproduct NUMBER FUNCTION to CREATE or REPLACE
IS
max_date_product VARCHAR2 (100);
BEGIN
BEGIN
SELECT NVL (TRIM (product_code), 0)
IN max_date_product
FROM (SELECT product_code, xref_end_dt)
PRODUCT
WHERE TO_NUMBER (p_product) = pr.item_id
ORDER BY xref_end_dt DESC)
WHERE ROWNUM = 1; -He'll be back a single line - max date product code
EXCEPTION
WHILE OTHERS
THEN
RETURN 0;
END;
RETURN max_date_product;
END maxdateproduct;
Thanks in advance.Hello
Something like that.
update setlls_table st set selling_code =(select nvl(trim(product_code)) from (select product_code , rank() over (partition by item_id order by xref_end_dt DESC) rn from product ) pr where rn =1 and pr.item_id = st.ctd_vpk_product_code ) where NVL(update_product_flag,0) = 0 ;
That such is not tested due to lack of sampling input.
Concerning
Anurag Tibrewal. -
Do not download the new update, States not connected to Internet
I recently bought an iPad pro, and the new update is due. I tried several times to do it, but it keeps telling me that it cannot connect to the Internet to do it, once I go through the process agree to the terms. However, I am here, on the internet very well. There is a lot of space, only had this for about a week and no further questions, I noticed.
Any advice?
Thank you
Due to problems with the update on iPad Pro 9.7 ", the update has been removed by Apple for this device.
If you have several iPad Pro, I would recomment still wait for a newer version.
-
How to upgrade several records or table using single update statement.
Hello friends,
I'm going to abc and xyz table.
ABC: columns
Ein, equipementid
1-99999
2 99999
3 99999
total records 1000
columns of XYZ:
Ein, equipementid
1 1234
2 3456
2 4567
4 4567
total records 10000000
I want equipmentid update table abc with equipmentid table xyz for ein game (like abc.ein = xyz.ein) and then had to delete record from table xyz corresponds to ein and equipentid who has updated the record in abc.
Note: If you see xyz for ein table 2 we have two different equipmentid, we update with any value and only the record of xyz must be deleted once updated.
A single declaration for the update and only statement needing to remove.
Appreciate your help.
Thank you / kumar
Published by: kumar73 on August 2, 2012 13:02Maybe
merge into abc using (select ein,max(equipmentid) equipmentid from xyz group by ein ) x on abc.ein = x.ein when matched then update set abc.equipmentid = x.equipmentid delete from xyz where exists(select null from abc where ein = xyz.ein and equipmentid = xyz.equipmentid )
Concerning
Etbin
-
Is it possible to fix this parent/child check in a single UPDATE statement?
I can find a not-very-effective solution to the problem after using PL/SQL. However, I am sure that there must be an easier way, using a SQL UPDATE. I was wondering if someone could help me please?
I have a simple table containing 7 rows. Each record is a "parent" or "child". The name is irrelevant. A child is bound to his registration parent via the parent_id. The problem is with the COUNTRY column. All children records COUNTRY values are correct. I need to ensure that all parents have the same value of COUNTRY as do their child records.
- ID = 1 shows an example of a COUNTRY that is missing. It should be filled with the value of the COUNTRY of its children files (ID = 2 and 3), which is "EN".
- ID = 4 shows an example where the parent COUNTRY record is incorrect as "US". It must be filled with registration of her child (ID = 5) COUNTRY of "FROM".
- Some parent lines are properly filled for example ID = 6
- There will never be a situation where a parent record has child records with different countries. The child records will always show the COUNTRY. If several records of the child the COUNTRY will be the same.
Is it possible in block update entire table based on the 4 guidelines above?
-- create table create table attendees( id number, attendee_type varchar2(6), name varchar2(12), country varchar2(2), parent_id number);
-- populate table insert into attendees(id, attendee_type, name) values(1, 'parent', 'John Doe'); insert into attendees(id, attendee_type, name, country, parent_id) values(2, 'child', 'James Doe', 'FR', 1); insert into attendees(id, attendee_type, name, country, parent_id) values(3, 'child', 'Sarah Doe', 'FR', 1); insert into attendees(id, attendee_type, name, country) values(4, 'parent', 'Paul Black', 'US'); insert into attendees(id, attendee_type, name, country, parent_id) values(5, 'child', 'Sam Black', 'DE', 4); insert into attendees(id, attendee_type, name, country) values(6, 'parent', 'Alan White', 'GB'); insert into attendees(id, attendee_type, name, country, parent_id) values(7, 'child', 'Louise White', 'GB', 6);
Hello
Something like:
MERGE INTO presence t1
USING (SELECT distinct id, country, country prior child_country)
Participants
WHERE parent_id is null and before the country is not null
CONNECT BY id = parent_id PRIOR
) t2
WE (t1.id = t2.id)
WHEN MATCHED THEN UPDATE SET t1.country = t2.child_country;
-
How to optimize the update statement so that the query is reading the same table?
Hi all
I have a process with the following UPDATE statement:
Sales_val update
SET ship_date =)
Select max (hist.ship_date)FROM sales_hist hist
WHERE hist. X_ID = A.X_ID
AND hist. X_VAL = A.X_VAL)
) WHERE EXISTS (select * from sales_hist hist where )
WHERE hist. X_ID = A.X_ID
AND hist. X_VAL = A.X_VAL
)
sales_val - 50 lines mln (unique index)
sales_hist - 20 mln ranks (unique index)
I met many problems with waits and locks - how to optimize to avoid locks using the parameters of tables or changes of the declaration? or maybe is there another way to do optimization ?
Kind regards
Bolo
Thank you for that. Collect in bulk Unfortunatelly + FORALL does not work with the types in 10g - solution is to use the FOR loop and is not as effective as FORALL in many cases. I do still some tests to solve this problem - I'll put you once it's done.
EDIT: hash partitioning + fusion - 3-5 minutes (time), so for now it's the solution to the problem. Thank you all for the great discussion!
-
line blocking during the update statement
HelloUsing Oracle 11 g 2. If I call the following update statement of meeting A, meeting A locks the line until a statement commit / rollback is emanating from the session has. If the session B calls the same statement was updated and the same line, session B will have to wait until the lock is released in the session. However, application developers are expressed in terms of discussions. Would it be possible that the update statement is called in the same session by several requests? If so, the case statement can be evaluated without the line being locked which could lead to erroneous results? Trying to keep this short message.
tableA has column (number of key, primary) and columnB (number)
{
Update tableA
Define columnB = case when columnB = 3 then
4
When columnB = 4 then
5
on the other
columnB
end
When columnA = 6;
}
2 applications (almost at the same time) in the same session could assess columnB 3. The goal would be the first query sets in column 4 and the second request sets in column 5.
> However, application developers are expressed in terms of discussions.
Of course, they are...
But each application thread will have its own dedicated database session.
-
Need help with update statement to be used in the stored procedure
I have the following update statement and I get "ORA-06512. Someone of you can help me.
----
UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
WHERE X.MOID in (UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
WHERE X.MOID in (A_TEMP_INT1, (select assocchild from mo_association
Connect prior assocchild = assocparent
Start with assocparent = A_TEMP_INT1)); (by selecting assocchild in mo_association
Connect prior assocchild = assocparent
Start with assocparent = A_TEMP_INT1));
----
Note: A_TEMP_INT1 and A_TEMP_INT3 are the values of cursor and is assigned to numeric values in the code.
Thanks for all the help in advance.
Kind regards
REDAWHERE X.MOID IN (SELECT ASSOCCHILD FROM MO_ASSOCIATION CONNECT BY PRIOR ASSOCCHILD = ASSOCPARENT START WITH ASSOCPARENT = A_TEMP_INT1 UNION SELECT A_TEMP_INT1 FROM DUAL );
Should work.
VR,
Sudhakar B. -
Concepts: how much writing on disk for a single update
(I use 10.2.0.5 but I think that this applies to any version)
After reading lots of documentation on Oracle I started to think how often Oracle 'written' for a single update statement.
The following is correct?
For an update statement:
(1) the original data are written in tables UNDO space
(2) this is protected by a write first to REDO log
(3) the new data is written to the table space
(4) this is also protected by an entry first in the redo log
(5) after that fills in the redo log, it is copied to an archived log
(6) at the time of the backup that Archives archiving log is also best once more
So for a single update, I count at least six entries of the same data?
It is probably what makes the robust Oracle.user12204556 wrote:
(I use 10.2.0.5 but I think that this applies to any version)After reading lots of documentation on Oracle I started to think how often Oracle 'written' for a single update statement.
The following is correct?
For an update statement:
(1) the original data are written in tables UNDO spaceYes
(2) this is protected by a write first to REDO log
Yes
(3) the new data is written to the table space
No, your data still haven't write (immediately) to datafiles (your tablespaces logically). When point of control (when manually to CHANGE the point of VERIFICATION SYSTEM, SWITCH of NEWSPAPER, when the buffer cache is full, STOP IMMEDIATELY in backup database tablespace mode) then your blocks of data will apply to data files.
(4) this is also protected by an entry first in the redo log
Yes
(5) after that fills in the redo log, it is copied to an archived log
YesIn ARCHIVELOG mode()
(6) at the time of the backup that Archives archiving log is also best once more
YES.
So for a single update, I count at least six entries of the same data?
These are not same data! This is the mechanism of oracle database. Cancel the information generated immediately and ensure uniformity reading (to restore). Redo information just, contain no information. It comes to redo change agent who used methods of recovery (media and instance) and finally your data updates do not immediately write data by DBWR because files there is reason of performance.
-
Hello
I wrote an update statement as below:
Update (select a.col1, a.col2 from table1, table2 b
where a.pk1 = b.pk1 and
a.PK2 = b.pk2 and
a.PK3 = b.pk3 and
a.PK4 in)
Select a.pk4 from table1, table2 b
where a.pk1 = b.pk1 and
a.PK2 = b.pk2 and
a.PK3 = b.pk3
less
Select pk4 from table2
)
) s
Set s.col1 = 'I ',.
s.col2 = null;
Table1 is a base table and the primary key for this table is made of CP1, CP2, pk3, pk4.
Table 2 is a temporary table with no primary key column.
My goal is to update the columns of table 1.
I'm using the code above in a procedure and this error:
ORA-01779: cannot modify a column that is mapped to a table not preserved key
I'm sure that the error has to with the foregoing update statement.
I have read a few articles and realize that Oracle can understand what table to update in this scenario. But I am at a loss to rewrite this query.
Please advice, how I can rewrite this query.
Thank you!Hello
Instead of updating a view online, update your actual table, like this:
UPDATE table1 SET col1 = 'I' , col2 = NULL WHERE (col1, col2, col3, col4) IN ( SELECT ... FROM table1 JOIN table2 ... ) ;
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002} -
How can I improve performance Adobe CS5?
I got a trial of Adobe Creative Suite 5 on a PC at work and so far it's ok, but it's really trolling. The PC currently has an Intel Core 2 Quad Q9400 2.66 GHz, 4 GB of Ram DDR2, 160 GB HDD, and an integrated Intel graphics chip.
Add a dedicated graphics card will improve performance of CS5? I read on the forums that Mac users use a 2nd hard drive as a "scratch disk" for the likes of photoshop which improves performance but do not know how to implement that.
Any ideas would be great.
The integrated graphics may well take all system RAM. In addition, you enter your operating system but I recommend Win 7 64 bit with a boat load of RAM.
Fast hard drives with a drive of dedicated work will help, too.
Bob
-
Performance issue with the Update statement
Oracle 10204
I have a problem related to updaing one performance table.
only 5000 lines should be updated.
Hir are some details on the tables/M.V concerned:
I tried to run the update with two options:TABLE_NAME LAST_ANALYZED NUM_ROWS SAMPLE_SIZE PS_RF_INST_PROD 1/20/2010 1:14:22 AM 7194402 7194402 BL_TMP_INTRNT 1/27/2010 9:08:54 AM 885445 885445 NAP_INTERNET 1/25/2010 11:47:02 AM 7053990 560777
1. with the plan than oracle choose.
2. with notes I added.
In both cases I he collapsed after more than an hour.
Can any one suggest how to speed it up?
Below are for the two option tkprof.
Plan 1Please note that beside the defualt statistics on those tables i also gathered statistics on two column level as followed: BEGIN SYS.DBMS_STATS.GATHER_TABLE_STATS ( OwnName => 'B' ,TabName => 'BL_TMP_INTRNT' ,Estimate_Percent => 100 ,Degree => 8 ,Cascade => TRUE ,No_Invalidate => FALSE); END; / exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns SERVICE_UID size 254'); exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns FIX_IP_USER size 254');
plan 2UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.03 0.02 0 0 0 0 Execute 1 1166.64 4803.78 17989002 18792167 117 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 1166.67 4803.81 17989002 18792167 117 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=2 us) 46 TABLE ACCESS FULL BL_TMP_INTRNT (cr=586400 pr=22228 pw=0 time=15333652 us) 15 HASH JOIN (cr=18170453 pr=17931639 pw=0 time=3991064192 us) 46 MAT_VIEW ACCESS FULL NAP_INTERNET (cr=5659886 pr=5655436 pw=0 time=988162557 us) 329499624 MAT_VIEW ACCESS FULL PS_RF_INST_PROD (cr=12545734 pr=12311281 pw=0 time=2636471644 us)
UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT /*+ index(b NAP_INTERNET_PK) index(c PS_RF_INST_PROD_PK)*/ C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.02 0.02 0 0 0 0 Execute 1 4645.25 4613.70 95783 39798095 735 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 4645.27 4613.73 95783 39798095 735 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=1 us) 473 TABLE ACCESS FULL BL_TMP_INTRNT (cr=10461 pr=10399 pw=0 time=4629385 us) 408 MAT_VIEW ACCESS BY INDEX ROWID PS_RF_INST_PROD (cr=39776109 pr=85381 pw=0 time=4605125045 us) 1350 NESTED LOOPS (cr=39784584 pr=84974 pw=0 time=4601874262 us) 470 MAT_VIEW ACCESS BY INDEX ROWID NAP_INTERNET (cr=23569112 pr=50472 pw=0 time=2544364336 us) 470 INDEX FULL SCAN NAP_INTERNET_PK (cr=23568642 pr=50005 pw=0 time=2540300981 us)(object id 11027362) 408 INDEX FULL SCAN PS_RF_INST_PROD_PK (cr=16215472 pr=34502 pw=0 time=2057500175 us)(object id 10980137) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 1300 0.50 4.27 db file sequential read 85707 0.51 29.88 latch: cache buffers chains 1 0.00 0.00 log file sync 1 0.00 0.00 SQL*Net break/reset to client 1 0.00 0.00 SQL*Net message to client 1 0.00 0.00 SQL*Net message from client 1 14.73 14.73 ********************************************************************************
The problem in your update statement that is the query in your set clause is executed many times that there are lines in BL_TMP_INTRNT of 'intellectual property' in their column of term_desc. You mentioned there are about 5000, then the query joining NAP_INTERNET with PS_RF_ISNT_PROD is begun 5000 times.
The trick is to join only once, be updated using join views - provided that it is preserved - key or by using the merge statement.Here is an example:
SQL> create table bl_tmp_intrnt (fix_ip_user,service_uid,term_desc) 2 as 3 select level 4 , level 5 , 'aipa' 6 from dual 7 connect by level <= 5000 8 / Tabel is aangemaakt. SQL> create table nap_internet (inst_prod_id,setid,nap_surf_uid) 2 as 3 select level 4 , 'SHARE' 5 , level 6 from dual 7 connect by level <= 10 8 / Tabel is aangemaakt. SQL> create table ps_rf_inst_prod (product_id,inst_prod_id) 2 as 3 select level 4 , level 5 from dual 6 connect by level <= 10 7 / Tabel is aangemaakt. SQL> exec dbms_stats.gather_table_stats(user,'bl_tmp_intrnt') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'nap_internet') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'ps_rf_inst_prod') PL/SQL-procedure is geslaagd. SQL> set serveroutput off SQL> update ( select a.fix_ip_user 2 , c.product_id 3 from bl_tmp_intrnt a 4 , nap_internet b 5 , ps_rf_inst_prod c 6 where a.term_desc like '%ip%' 7 and a.service_uid = b.inst_prod_id 8 and b.setid = 'SHARE' 9 and b.nap_surf_uid = c.inst_prod_id 10 ) 11 set fix_ip_user = product_id 12 / set fix_ip_user = product_id * FOUT in regel 11: .ORA-01779: cannot modify a column which maps to a non key-preserved table
Join is one key kept in the case of b.inst_prod_id and c.inst_prod_id are unique. Please refer to the documentation for more information here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3055
SQL> alter table nap_internet add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> alter table ps_rf_inst_prod add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> update /*+ gather_plan_statistics */ 2 ( select a.fix_ip_user 3 , c.product_id 4 from bl_tmp_intrnt a 5 , nap_internet b 6 , ps_rf_inst_prod c 7 where a.term_desc like '%ip%' 8 and a.service_uid = b.inst_prod_id 9 and b.setid = 'SHARE' 10 and b.nap_surf_uid = c.inst_prod_id 11 ) 12 set fix_ip_user = product_id 13 / 10 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID c7nqbxwzpyq5p, child number 0 ------------------------------------- update /*+ gather_plan_statistics */ ( select a.fix_ip_user , c.product_id from bl_tmp_intrnt a , nap_internet b , ps_rf_inst_prod c where a.term_desc like '%ip%' and a.service_uid = b.inst_prod_id and b.setid = 'SHARE' and b.nap_surf_uid = c.inst_prod_id ) set fix_ip_user = product_id Plan hash value: 1745632149 --------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | --------------------------------------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.01 | 32 | | | | | 2 | NESTED LOOPS | | 1 | 10 | 10 |00:00:00.01 | 21 | | | | | 3 | MERGE JOIN | | 1 | 10 | 10 |00:00:00.01 | 9 | | | | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 1 | 10 | 10 |00:00:00.01 | 2 | | | | | 5 | INDEX FULL SCAN | SYS_C00132995 | 1 | 10 | 10 |00:00:00.01 | 1 | | | | |* 6 | SORT JOIN | | 10 | 250 | 10 |00:00:00.01 | 7 | 267K| 256K| 237K (0)| |* 7 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | | | | 8 | TABLE ACCESS BY INDEX ROWID | PS_RF_INST_PROD | 10 | 1 | 10 |00:00:00.01 | 12 | | | | |* 9 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | | | | --------------------------------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 4 - filter("B"."SETID"='SHARE') 6 - access("A"."SERVICE_UID"="B"."INST_PROD_ID") filter("A"."SERVICE_UID"="B"."INST_PROD_ID") 7 - filter("A"."TERM_DESC" LIKE '%ip%') 9 - access("B"."NAP_SURF_UID"="C"."INST_PROD_ID") 32 rijen zijn geselecteerd. SQL> rollback 2 / Rollback is voltooid.
And it's your current statement. Please note the number of 5000 in the column begins:
SQL> UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A 2 SET A.FIX_IP_USER = 3 (SELECT C.PRODUCT_ID 4 FROM NAP_INTERNET B, PS_RF_INST_PROD C 5 WHERE B.INST_PROD_ID = A.SERVICE_UID 6 AND B.SETID = 'SHARE' 7 AND C.INST_PROD_ID = B.NAP_SURF_UID) 8 WHERE A.TERM_DESC LIKE '%ip%' 9 / 5000 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID f1qtnpa0nmbh8, child number 0 ------------------------------------- UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' Plan hash value: 3190675455 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | ----------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.10 | 5076 | |* 2 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | 3 | NESTED LOOPS | | 5000 | 1 | 10 |00:00:00.02 | 24 | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 5000 | 1 | 10 |00:00:00.01 | 12 | |* 5 | INDEX UNIQUE SCAN | SYS_C00132995 | 5000 | 1 | 10 |00:00:00.01 | 2 | | 6 | TABLE ACCESS BY INDEX ROWID| PS_RF_INST_PROD | 10 | 10 | 10 |00:00:00.01 | 12 | |* 7 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("A"."TERM_DESC" LIKE '%ip%') 4 - filter("B"."SETID"='SHARE') 5 - access("B"."INST_PROD_ID"=:B1) 7 - access("C"."INST_PROD_ID"="B"."NAP_SURF_UID") 29 rijen zijn geselecteerd.
Kind regards
Rob. -
Updates using the single SQL Update statement.
Hi guys,.
I got an interview... and was not able to answer a question.
In view of the table emp... need to update the salary with the following requirement by using an SQL statement.
1 update salary + 1000 for employees who receive pay between 500 and 1000
2 update salary + 500 for employees who receive wages between 1001 and 1500
The two above the requirement should be made using only a SQL update statement... can someone tell me how to do?update emp set salary = case when salary between 500 and 1000 then salary + 1000 when salary between 1001 and 1500 then salary + 500 end;
Concerning
Arun
Maybe you are looking for
-
Windows 10, 12.something. Click Help-> about iTunes, and it begins to scroll the information we. It will not stop. I can't enter text with Ctrl-c. Nice feature. (sarcasm) Which once again: 12.4.3.1 Shuffle was working, then it suddenly stopped. T
-
How can I configure the 9 pages 'home' on the 'new tab '.
There are 9 boxes 'home' to pin 9 sites on the 'new tab', for easy access to favorite sites.How I can pin to stay up, when I can't even bring up the empty spot?I know how to "attach" the tabs at the top and I know how to "pin" a page on the 'new' tab
-
Find a picture of corrupt so I can delete
When I try to sync my iPhone of 6 photos on my Mac, 2 photos (maybe) corrupt cannot import. Under the "news pictures (2 pictures)" label I see 2 grey squares that contain a default photo icon (2 overlapping rectangles).»» I would really like to delet
-
Hey guys, I had problems with Skype on my iPhone for a long time. And this happens only when I'm NOT on WIFI. Whenver someone present me a message, the message will be displayed on my phone as a notification. I always get these any problem. But when
-
Album artwork is more important to CD
Please I need help and iTunes ceased to import a CD work with the 3 latest updates to iTune. No problems with the import of CD work or using Get Album work AFTER importing from a CD until the 3rd update of iTune and problem persists. Program: iTunes