UPDATE statement performance optimization (batch update)

UPDATE (
    select   gr.gr_sfz  ,s.sfz   
from gerenkehu gr ,fw_bz s
     where gr.gr_id=s.code
   and s.sfz is not null)
set gr_sfz=sfz;


Execution error: ORA-01779 cannot modify the column corresponding to the non-key value storage table

Analysis : The way to construct the intermediate table update requires that the key value of the association condition must be a unique value
create unique index IX_FW_BZ_CODE on FW_BZ (CODE);


Use BYPASS_UJVC to enforce, BYPASS_UJVC can skip Oracle's key checking.
SQL> UPDATE
  2 (
  3 SELECT /*+BYPASS_UJVC*/ A.ID AI,A.GENDER AG,B.ID BI,B.GENDER BG FROM TEST1 A, TEST2 B WHERE
  4 A.ID = B.ID
  5 )
  6 SET AG = BG;

2 rows updated.
Although this works, there is non-unique data in test2, so test1 may be updated multiple times.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326179835&siteId=291194637