MEGER sentence in oracle
MEGE Sentence
This oracle tutorial explains how to use the oralce MEGER sentence with syntax and samples.
Description
The MEGE sentence aim to reduce operator sentences.
Syntax
The syntax for the MEGE sentence is
MEGE <hint>
INTO <TABLE_NAME>
USING <table_view_or_query>
ON (<condition>)
WHERE MATCH THEN <update_clause>
DELETE <where_clause>
WHERE NOT MATCHED THEN <insert_clause>
[LOG ERRORS <log_errors_clause> <reject limit <integer | unlimited>];
Example
CREATE TABLE dept60_bonuses(
employee_id NUMBER,
bouns_amt NUMBER
);
INSERT INTO dept60_bonuses VALUES(103,0);
INSERT INTO dept60_bonuses VALUES(104,0);
INSERT INTO dept60_bonuses VALUES(105,0);
commit;
SELECT employee_id,last_name,salary
FROM employees
WHERE department_id=; MERGE INTO dept60_bonuses b
USING(
SELECT employee_id,salary,department_id
FROM employees
WHERE department_id=60) e
ON (b.employee_id=e.employee_id)
WHEN MATCHED THEN
UPDATE SET b.bouns_amt=e.salary*2
WHERE b.bouns_amt=0
DELETE WHERE (e.salary>7500)
WHEN NOT MATCHED THEN
INSERT (b.employee_id,b.bouns_amt)
VALUES (e.employee_id,e.salary*0.1)
WHERE (e.salary<7500);
MEGER sentence in oracle的更多相关文章
- Oracle Meger into 函数
Oracle 在 9i 引入了 merge 命令, 通过这个 merge 能够在一个SQL 语句中对一个表同时执行 inserts 和 updates 操作.Merge into 可以实现用 B 表来 ...
- Oracle Database 11g express edition
commands : show sys connect sys as sysdba or connect system as sysdba logout or disc clear screen or ...
- about oracle
Oracle 劳伦斯.埃里森 Larry Ellison history: 人工管理阶段 文件管理阶段 数据库系统阶段 model:[模型是所研究的系统.过程.事物或概念的一种表达形式] 层次结构m ...
- Working with Strings(使用Oracle字符串)
Working with Strings By Steven Feuerstein Part 3 in a series of articles on understanding and using ...
- VBS连接远程Oracle
原文链接:http://hi.baidu.com/coo_boi/item/5a2e1860ded285136995e6a7 连接方式还是用的ADO,驱动是MSDAORA. 使用oracle前,ora ...
- Analytic Functions in Oracle
Contents Overview and IntroductionHow Analytic Functions WorkThe SyntaxExamplesCalculate a running T ...
- oracle 基本语法(一)
1.基本语句: .查询每个部门工资最高的人的详细记录 select * from emp e,(select max(sal) max,deptno from emp group by deptno) ...
- 转:c++ Oracle OCCI 编程
原地址http://blog.sina.com.cn/s/blog_53a72add01015zj4.html 找不到具体的出处,只好不写了. OCCI数据库ORACLE编程步骤1. 配置环境(1) ...
- c++ Oracle OCCI 编程
转载备忘:http://blog.sina.com.cn/s/blog_53a72add01015zj4.html 关于occi编程可以参考的链接: http://blog.itpub.net/162 ...
随机推荐
- SqlServer索引优化 查看碎片情况
本文引自 DBCC DBREINDEX重建索引提高SQL Server性能 查看碎片情况使用 dbcc showcontig 函数来进行 代码: --改成当前库 use DB_Name --创建变量 ...
- android 小工具:pc 上用 curl 命令打开手机浏览器,浏览指定网址
测试 API 时或其它情况经常需要在手机浏览器中输入 url 一长串的 url 输起来真是麻烦 AirDroid 很强大也不用数据线,但有时老断开连接,不是很爽.发到手机 qq 吧还得手动粘贴 所以自 ...
- 分布式集群HBase启动后某节点的HRegionServer自动消失问题
详细问题 我这里是,我的这个slave1的HRegionServer 进程启动后,不久自动消失. 去查看日志,排查问题: 发现问题: 解决办法 [hadoop@master h ...
- 9.1_the end
选择题 1.考察正则,书写一个6位数的邮箱 a var mail=/\d{6}/; b var mail=new RegExp("/\d{6}/"); 分析:对a,应该要添加开头和 ...
- C 标准库 - string.h
C 标准库 - string.h This header file defines several functions to manipulate C strings and arrays. stri ...
- MySQL使用全文索引(fulltext index)
1.创建全文索引(FullText index) 旧版的MySQL的全文索引只能用在MyISAM表格的char.varchar和text的字段上. 不过新版的MySQL5.6.24上InnoDB引擎也 ...
- 九度oj 1006 ZOJ问题 2010年浙江大学计算机及软件工程研究生机试真题
题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16244 解决:2742 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC.是 ...
- Javascript 中 atob/btoa
解决 Javascript 中 atob 方法解码中文字符乱码问题 由于一些网络通讯协议的限制,你必须使用 window.btoa() 方法对原数据进行编码后,才能进行发送.接收方使用相当于 wind ...
- [PY3]——找出一个序列中出现次数最多的元素/collections.Counter 类的用法
问题 怎样找出一个序列中出现次数最多的元素呢? 解决方案 collections.Counter 类就是专门为这类问题而设计的, 它甚至有一个有用的 most_common() 方法直接给了你答案 c ...
- SSRS Report Knowledge Base
1. 获取Textbox的值,根据Textbox值更改单元格颜色 Textbox值:=ReportItems!Textbox1.Value 当前单元格的值:=Me.Value =IIF(ReportI ...