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);

最新文章

  1. UITableView点击每个Cell,Cell的子内容的收放
  2. VIM编辑器之常用命令
  3. 关于IE6中做兼容的那点事。
  4. Linux内核设计第六周 ——进程的描述和创建
  5. 为什么学习Ruby On Rails:
  6. 非聚集索引中的临界点(Tipping Point)
  7. 使用Maven构件Web应用
  8. 从gitbook将书籍导入到github中
  9. jQuery tablesort插件推荐
  10. Spring - Bean的概念及其基础配置
  11. Quick Brown Fox
  12. python+appium+unittest
  13. C++ STL的一些操作
  14. 谷歌chrome浏览器vue调试工具vue-devtools的安装
  15. Android为TV端助力 内存溢出与内存泄露
  16. c语言cJson数组生成与解析
  17. 大数据系列博客之 --- 深入简出 Shell 脚本语言(高级篇)
  18. 品尝阿里云容器服务:初步尝试ASP.NET Core Web API站点的Docker自动化部署
  19. Python+Flash+NodeJS 接口自动化平台
  20. NYOJ 一笔画

热门文章

  1. SQL端通过脚本判断文件夹是否存在 并创建
  2. redux-thunk, redux-logger 阮一峰 ( react中间件 )
  3. user agent stylesheet -- 浏览器默认样式
  4. Netty构建Http服务器
  5. Jmeter调试脚本之断言
  6. Flink安装极简教程-单机版
  7. 为easyui添加多条件验证
  8. 30 行代码实现 JS 中的 MVC
  9. log4j 简单用法
  10. 阿里云配置HTTPS