null时会插入啊OPER@tl> select * from test; AAA BBB ---------- ---------- 1 1OPER@tl> merge into test a using (select null aaa from dual) b 2 on (a.aaa=b.aaa) 3 when matched then update set a.bbb=999 4 when not matched then insert values(0,0) 5 /1 行已合并。OPER@tl> select * from test; AAA BBB ---------- ---------- 1 1 0 0OPER@tl>
---------- ----------
1 1OPER@tl> merge into test a using (select null aaa from dual) b
2 on (a.aaa=b.aaa)
3 when matched then update set a.bbb=999
4 when not matched then insert values(0,0)
5 /1 行已合并。OPER@tl> select * from test; AAA BBB
---------- ----------
1 1
0 0OPER@tl>
不要再纠结于merge into.
是using出来的结果,跟要MERGE INTO的表比较,有就更新,没有就插入