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