The saveOrUapdate and mergesaveoruapdate in merge into Oracle
1. Initial data:
SQL> select * from a; ID NAME---------------------- ----------------------1 12 13 14 15 1SQL> select * from b; ID NAME---------------------- ----------------------1 22 211 11
2. Objective: 1) update. name to B. name prevails; 2) if the id in Table B is not in Table a, copy the record in Table B and insert it to Table.
3. function implementation:
Merge into A a using B B on (. id = B. id) -- on is the matching condition when matched then -- Update. nameupdate set. name = B. name where 1 = 1 -- here we can add the where condition when not matched then -- copy and insert binsert values (B. id, B. name) where 1 = 1
Oracle problems? What about merge into in oracle?
Compare the two tables. You can compare the insert, update, and delete tables.
ORACLE usage of merge
After when matched then and when not matched then, only insert () values or update set ....,...., conditions cannot be attached, and other statements following then cannot be used. In addition, it is noted that the B domain is only useful for queries in using. If you want to use it, you must use M in Using () m.