作用:merge into 解決用B表跟新A表數據,如果A表中沒有,則把B表的數據插入A表; 語法: MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your query-sql and using just like a table] ON ([conditional expression here] AND [...]...) WHEN MATHED THEN [here you can execute some update sql or something else ] WHEN NOT MATHED THEN [execute something else here ! ] -------------------------------------實例----------------------------------------------------------------- merge into tfa_alarm_act_nms a 作用:利用表 tfa_alarm_status跟新表tfa_alarm_act_nms 的b.redefine_severity,條件是a.fp0=b.fp0 and a.fp1=b.fp1 and a.fp2=b.fp2 and a.fp3=b.fp3,如果tfa_alarm_act_nms表中沒有該條件的數據就插入。 如果你的數據量很大,此sql效率非常高。 |
oracle merge into 的用法詳解+實例