oracle中merge into..using..on..when..when..用法
来源:互联网 发布:源码怎么使用 编辑:程序博客网 时间:2024/05/17 21:39
语法:
作用:利用表 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效率非常高。
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 using (select FP0,FP1,FP2,FP3,REDEFINE_SEVERITY from tfa_alarm_status) b on (a.fp0=b.fp0 and a.fp1=b.fp1 and a.fp2=b.fp2 and a.fp3=b.fp3) when matched then update set a.redefine_severity=b.redefine_severity when not matched then insert (a.fp0,a.fp1,a.fp2,a.fp3,a.org_severity,a.redefine_severity, a.event_time ,a.int_id) values (b.fp0,b.fp1,b.fp2,b.fp3,b.REDEFINE_SEVERITY,b.redefine_severity,sysdate,7777778);
作用:利用表 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效率非常高。
转自:http://azrael6619.iteye.com/blog/759678
0 0
- oracle中merge into..using..on..when..when..用法
- oracle中merge into..using..on..when..when..用法
- oracle中merge into..using..on..when..when..用法 使用一条语句实现update/insert 语句
- Oracle 中 merge into when 的用法分析。
- MERGE INTO USING ON WHEN MATCHED THEN WHEN NOT MATCHED THEN
- Oracle中case when用法
- Oracle merge into using 的用法
- Oracle sequence increased unexpected when using in merge statement
- oracle 中merge into用法
- oracle中merge into用法
- oracle数据库中 case when的用法
- Oracle中CASE WHEN的用法实例
- Oracle中CASE WHEN的用法实例
- Oracle中CASE WHEN的用法实例
- Oracle 中case when的用法
- oracle case when 用法
- Oracle case when 用法
- Oracle case when用法
- 机器学习知识图谱
- 防止frame框架中出现login页面
- vuejs标签切换demo
- mysql lower_case_table_names 参数引起的一起事故
- C# winform点击生成二维码
- oracle中merge into..using..on..when..when..用法
- 用枚举实现单例
- matlab写文件与导出数据(fprintf,dlmwrite,xlswrite)
- SpringMVC注解实现登录验证
- 插入排序法
- 第2章 关系模型介绍
- 北大ACM试题分类
- iOS 清除通知中心收到的APNS通知
- Kafka初识