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 ...
随机推荐
- 在Eclipse或工作空间中 ,复制或修改项目后,把项目部署后发现还是原来的项目名称
1 问题引出 1 在eclipse中直接复制一个项目,修改名称之后,然后部署,部署之后的项目名称还有原来的项目名称 2 在eclipse的工作空间中直接复制一个项目,修改名字之后,发布也会出现同样的问 ...
- 【linux】虚拟机内装Linux系统的ssh访问
一般在虚拟机内安装一个Linux系统,虚拟机网络设置为桥接后,Linux系统会在安装的过程中自动设置其为dhcp配置,会给其随机分配一个ip,这个ip可以用命令 "ifconfig" ...
- ubuntu16上安装openJDK.md
ubuntu16上安装openJDK.md 环境 操作系统:ubuntu 16.04.2 LTS 安装 当你不需要安装oracle的JDK时,使用openJDK,安装就比较方便. sudo apt-g ...
- C 标准库 - string.h之strrchr使用
strrchr Locate last occurrence of character in string, Returns a pointer to the last occurrence of c ...
- Python基础(1) - 初识Python
Python 特点: 1)面向对象 2)解释执行 3)跨平台.可移植 4)垃圾回收机制 5)动态数据类型.强类型 6)可扩展.可嵌入 Python可以方便调用C/C++等语言,同时也可以方便的被C/C ...
- Linux 线程实现机制分析--转
http://www.ibm.com/developerworks/cn/linux/kernel/l-thread/ 一.基础知识:线程和进程 按照教科书上的定义,进程是资源管理的最小单位,线程是程 ...
- angularjs之UI Grid 的刷新 本地数据源及HTTP数据源
关键代码: 如果数据源是本地数据$("#hidJsonData").val("[]"); var myJsonData = []; if ($(&quo ...
- Spring学习(一) IoC
文章部分图片来自参考资料,本文介绍的是 Spring 的两个重要概念,是学习总结. 我们依旧提出几个问题,帮助我们在学习中带着问题解答. 问题 : 如何理解Ioc,它解决了什么难题(或者说是使用它 ...
- ThreadLocal介绍以及源码分析
ThreadLocal 线程主变量 前面部分引用其他优秀博客,后面源码自己分析的,如有冒犯请私聊我. 用Java语言开发的同学对 ThreadLocal 应该都不会陌生,这个类的使用场景很多,特别是在 ...
- 插入排序——Python实现
一.排序思想 排序思想参见:https://www.cnblogs.com/luomeng/p/10583124.html 二.python实现 def InsertSort(arrs): " ...