UPDATE multiple tables in Oracle
The following methods can be implemented:
One is:
Update table1
Set (field1, field2. ..) =
(Select Field1, field2 ....
From table2
Where table1.field1 = table2.field1)
Where table1.field1 in (select field1 from table2)
Two types are:
Associate fields table1 and table2 with the PRimary key or Union key.
Update (Select Table1.field1, table1.field2, table2.field1, table2.field2
From table1, table2
Where Table1.Field1 = table2.field1)
Set table1.table2 = table2.table2,
Table1.fieldn = table2.tablen,
......
For Field1 of table1 and field1 of table2, you must create a primary key or a unique index.
Three types are:
Merge into table1
Using table2
On (table1.field1 = table2.field1 and ....)
When matched then Update set table1.field2 = table2.field2,
Table1.fieldn = table2.fieldn,
......
When not matched then [doing other thing]
The cursor can be used for other methods.