[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中的一个 ...
随机推荐
- sqoop将关系型的数据库得数据导入到hbase中
1.sqoop将关系数据库导入到hbase的参数说明
- easyui js基础
$(document).ready( function(){ initload(); });function initConfig(){ //数据列表 yzfymx=$("#tjdj&quo ...
- Newtonsoft.Json(C#处理json)
转载自:http://blog.csdn.net/wswqiang/article/details/6783161 using Newtonsoft.Json; using System.Text; ...
- sqlserver查看被锁表、解锁
查看别锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys.d ...
- vim备忘
复制指定行 5,20co$(5到20行复制到最后一行之后) 指令模式下,c的使用方式与d相同,但删除后会进入INSERT模式 删除以某一符号开头或结尾的行 :%g/^\s/d(删除以空格开头的行) : ...
- 《Android深度探索》(卷1)HAL与驱动开发读后感
第1章:安卓系统移植与驱动开发概述 这一章主要概括的介绍了安卓驱动开发和系统移植的主要内容,对安卓与Linux驱动做了一个总体的介绍.通过对第一章的学习,使我对Linux驱动开发有了一个感性的认识.在 ...
- dedecms recommend 注入 exp
我看没人用python写过发过 所以我就发一下 喜欢用python的就用我这个吧 不喜欢的就用JAR那个或者PHP那个吧 #coding:GBK import re import urllib &q ...
- CI框架 CodeIgniter 伪静态 htaccess设置和Nginx伪静态方法
众所周知,LAMP代表Linux下Apache.MySQL.PHP这种网站服务器架构:而LNMP指的是Linux下Nginx.MySQL.PHP这种网站服务器架构.LNMP一键安装包可以从网上下载使用 ...
- Webview 与h5的交互
步骤:H5代码 <html> <head> <meta charset="UTF-8"> <title>交互Demo ...
- 关于 MAXScript 如何获取当前max版本
用到了 GetFileVersion 相关文档在此:http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files ...