KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know there is no Update-Join statement in PL/SQL. I used to write T-SQL. I have two tables. Alex_Table1 --------------------------- PK VAL --------------------------- 1 Value1 2 Value2 3 Value3 Alex_Table2 --------------------------- PK VAL --------------------------- 1 Value1_2 3 Value3_2 I want to update VAL from Alex_Table2 to Alex_Table1 joining by PK column. In T-SQL, that is simple update t1 set t1.VAL = t2.VAL from Alex_Table1 t1 inner join Alex_Table2 t2 on t1.PK = t2.PK; And the result is what I expected Alex_Table1 --------------------------- PK VAL --------------------------- 1 Value1_2 2 Value2 3 Value3_2 My question is how to do in PL/SQL? Thanks! Update Thanks Cybernate and ypercube gave me two useful solutions. They both work. However, I want to let you know the performance between these two statements. My actual table contains 80,000 records and only 3,000 needs update. MERGE statement takes 0.533 seconds. UPDATE EXISTS statement takes over 3 minutes ( I did not measure the actual time. I terminated my process after 3 minutes.)
Tags (comma-separated)
Save Edits
Cancel