[oracle] update和merge语句的几点写法
1.update t2 set parentid=(select ownerid from t1 where t1.id=t2.id);
2.
update tb_client_win_lost_report a set a.rolling_code_id=2
where game_code_id=70000
and exists
(select 'x' from (select a.id
from (select id,level_ from tb_admin_role connect by prior id=parent_id start with id =1) a,
(select lv_id from tb_rolling_plan where rolling_code_id = 2 and game_code_id=70000) b
where b.lv_id=a.id) c where a.role_id=c.id)
and rolling_code_id=1
3.
update (select rolling_code_id from tb_client_win_lost_report a,temp_role_id b
where a.role_id=b.id
and rolling_code_id=1) a set a.rolling_code_id=2;
4.
update tb_client_win_lost_report a set a.rolling_code_id=2
where game_code_id=70000
and exists
(select 'x' from (select id from temp_role_id) c where a.role_id=c.id)
and rolling_code_id=1
and rownum<100000;
commit;
5.
update 多个字段的写法
update a set (c1,c2,c3) =(select b1,b2,b3 from b where......) where ......;
merge语法
MERGE INTO table_name alias1
USING (table|view|sub_query) alias2
ON (join condition)
WHEN MATCHED THEN
UPDATE table_name
SET col1 = col_val1, col2 = col2_val
WHEN NOT MATCHED THEN
INSERT (column_list) VALUES (column_values);
merge into /*+ PARALLEL(t,4) */ QUESTIONNAIRE_20161011 t3
using ACCOUNT_FIRST_LAST_20161011 t
ON (t3.acount_id = t.account_id)
when matched then
update
set t3.first_login_date = t.min_record_date
, t3.last_login_date =t.max_record_date;
commit; --根据首登计算次留
merge into QUESTIONNAIRE_20161011 t3
using ( select distinct record_date, account_id from LOGIN_20161011) t
ON (t3.acount_id = t.account_id and t3.first_login_date+ = t.record_date )
when matched then
update set t3.day2 = ;
commit; --充值
merge into QUESTIONNAIRE_20161011 t3
using (select account_id, sum(pay_total) pay_total from PAY_20161011
group by account_id
) t
ON (t3.acount_id = t.account_id )
when matched then
update set t3.pay_total = t.pay_total;
commit;
[oracle] update和merge语句的几点写法的更多相关文章
- oracle 批量更新merge语句
merge into (SELECT * FROM QUERY_DB1.test_MPOS ) T1 using (SELECT FLAG FLAG1,IN_MNO FROM QUERY_DB1.t ...
- [Oracle] Merge语句
Merge的语法例如以下: MERGE [hint] INTO [schema .] table [t_alias] USING [schema .] { table | view | subquer ...
- Oracle中MERGE语句的使用
Oracle在9i引入了merge命令, 通过这个merge你能够在一个SQL语句中对一个表同时执行inserts和updates操作. 当然是update还是insert是依据于你的指定的条件判断的 ...
- Oracle Update 语句语法与性能分析 - 多表关联
Oracle Update 语句语法与性能分析 - 多表关联 为了方便起见,建立了以下简单模型,和构造了部分测试数据: 在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create ...
- Oracle doesn't have on duplicate key update Use MERGE instead:
Oracle doesn't have on duplicate key update Use MERGE instead: MERGE INTO my_table trg USING (SELECT ...
- Oracle 中MERGE语句的用法
原文章出处(http://blog.csdn.net/lichkui/article/details/4306299) MERGE语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语 ...
- Oracle基础之Merge into
Merge into语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语句. 通过MERGE语句,根据一张表或多表联合查询的连接条件对另外一张表进行查询,连接条件匹配上的进行UPDA ...
- ORACLE中的MERGE语法使用记录
项目中使用到了Oracle的MERGE INTO语句,在这里简单记录下使用方法 使用场景如下: 存在对一张数据量很大的表,你需要对里面的大量数据进行更新,如果数据不存在,就进行插入的操作. 常规想到的 ...
- 在oracle中使用merge into实现更新和插入数据
目录 oracle中使用merge into DUAL表解释 使用场景 用法 单表 多表 oracle中使用merge into DUAL表解释 在Oracle数据库中,dual是Oracle中的一个 ...
随机推荐
- url编码 中文在url参数中传递,在请求头,响应头中传递,是如何编码的呢?
一定要编码成url的吗?还是url自动把接受的汉字编码,请求头响应头到达之后再自动编码成汉字?这样似乎比较合理哦 先把iso8859-1 转换成 utf-8,在mvc中处理,然后响应的时候在转成iso ...
- iOS 10 UserNotifications 框架解析
摘自:https://onevcat.com/2016/08/notification/ iOS 10 中以前杂乱的和通知相关的 API 都被统一了,现在开发者可以使用独立的 UserNotifica ...
- Polymer.js
Polymer 1.0 教程 安装 bower install --save Polymer/polymer
- 今天<人人都能弹吉他>免费版获得了苹果的新品推荐
今天改了一天程序, 来回测来回改, 准备提交一个新版本了. 傍晚跑步回来, 看了一下今天的下载量, 竟然比昨天多了. 然后就想, 难不成被苹果推荐了? 上线一看, 果然, 而且美国和中国两大市场都在新 ...
- IT行业的正式入门
虽然我是计算机专业毕业的大学生,但我自己认为我连什么是 IT都不了解,我热爱Java程序的设计,所以我现在在努力学习,今天是上Java程序设计的第一天,我正式进入IT业,踏上了这条“不归路”.figh ...
- codeforces298c
link:http://codeforces.com/problemset/problem/298/C 这道题目可以看出来我智商确实拙计 #include <iostream> #incl ...
- linux之"server" directive is not allowed here in
配置完rewrite之后重启nginx发现如下错误 "server" directive is not allowed here in* 原因是因为 外部配置的simple.con ...
- Python 爬虫学习 网页图片下载
使用正则表达式匹配 # coding:utf-8 import re import urllib def get_content(url): """ Evilxr, &q ...
- Java 报表之JFreeChart(第一讲)
1.利用 JFreeChart 创建垂直柱状报表 package com.wcy.chart.bar; import javax.servlet.http.HttpSession; import or ...
- NET-SNMP配置
配置/etc/snmp/snmpd.conf such as below : ============================================== com2sec notCon ...