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语句的几点写法的更多相关文章

  1. oracle 批量更新merge语句

    merge into (SELECT * FROM QUERY_DB1.test_MPOS  ) T1 using (SELECT FLAG FLAG1,IN_MNO FROM QUERY_DB1.t ...

  2. [Oracle] Merge语句

    Merge的语法例如以下: MERGE [hint] INTO [schema .] table [t_alias] USING [schema .] { table | view | subquer ...

  3. Oracle中MERGE语句的使用

    Oracle在9i引入了merge命令, 通过这个merge你能够在一个SQL语句中对一个表同时执行inserts和updates操作. 当然是update还是insert是依据于你的指定的条件判断的 ...

  4. Oracle Update 语句语法与性能分析 - 多表关联

    Oracle Update 语句语法与性能分析 - 多表关联   为了方便起见,建立了以下简单模型,和构造了部分测试数据: 在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create ...

  5. 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 ...

  6. Oracle 中MERGE语句的用法

    原文章出处(http://blog.csdn.net/lichkui/article/details/4306299) MERGE语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语 ...

  7. Oracle基础之Merge into

    Merge into语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语句. 通过MERGE语句,根据一张表或多表联合查询的连接条件对另外一张表进行查询,连接条件匹配上的进行UPDA ...

  8. ORACLE中的MERGE语法使用记录

    项目中使用到了Oracle的MERGE INTO语句,在这里简单记录下使用方法 使用场景如下: 存在对一张数据量很大的表,你需要对里面的大量数据进行更新,如果数据不存在,就进行插入的操作. 常规想到的 ...

  9. 在oracle中使用merge into实现更新和插入数据

    目录 oracle中使用merge into DUAL表解释 使用场景 用法 单表 多表 oracle中使用merge into DUAL表解释 在Oracle数据库中,dual是Oracle中的一个 ...

随机推荐

  1. Android 生成颜色器

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...

  2. 【转】15个无比华丽的HTML5/CSS3动画应用

    原文转自:http://www.html5cn.org/article-7089-1.html 前几天,HTML5标准已经尘埃落定,未来的Web将会是由HTML5主导,当然作为开发者对这一喜讯更为动心 ...

  3. ✡ leetcode 166. Fraction to Recurring Decimal 分数转换 --------- java

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  4. 综合使用union和limit区分结果并限制返回结果集的条数

    limit , 这里的limit限制了返回的union(合并)后的结果集,

  5. 切换到android studio环境

    下载: android-studio-bundle-135.1740770-windows.exe sysimg_arm-21_r03.zip 设置环境变量: ANDROID_SDK_HOME     ...

  6. C#特性学习笔记一

    元数据,就是C#中封装的一些类,无法修改.类成员的特性被称为元数据中的注释. 1.什么是特性   1)属性与特性的区别 属性(Property):属性是面向对象思想里所说的封装在类里面的数据字段,Ge ...

  7. [solr] - 数据库导入

    这里使用的是mysql测试. 1.先在mysql中建一个表:solr_test 2.插入几条测试数据: 3.用记事本打solrconfig.xml文件,在solrhome文件夹中.E:\solrhom ...

  8. CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved

    CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin ...

  9. nodejs:express API之res.locals

    在从零开始nodejs系列文章中,有一个login.html文件 再来看它的get方法,我们并没有看到mess字段.那mess到底是从哪里来的呢? 接着我看到app.js文件里面: 只有这里出现了me ...

  10. [经验交流] Apache Mesos Docker集群初探

    前言 因工作需要,我对基于Apache Mesos 的 Docker 集群作了一点研究,并搭建了一套环境,以下是资料分享. 1. Apache Mesos概述 Apache Mesos是一款开源群集管 ...