Oracle中merge into的使用
来源:互联网 发布:瑞安法院淘宝拍卖网 编辑:程序博客网 时间:2024/06/06 16:50
语法:
MERGE INTO table_name alias1 USING (table|view|sub_query) alias2ON (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);
1.根据newproducts表 来更新products表( 使用表newproducts中的product_name 和category字段来更新表products 中相同product_id的product_name 和category)
MERGE INTO products p --MERGE INTO 跟的是我们要更新的表 USING newproducts np --USING 后面接的是条件表 ON (p.product_id = np.product_id) --ON 后面接的是要更新的表和条件表 连接的条件(可以有多个条件,多个条件用and连接) WHEN MATCHED THEN -- 满足ON 后面的条件 执行后面的语句(这里的语句是update也可以是insert into语句) UPDATE SET p.product_name = np.product_name, p.category = np.category;
2.当条件不满足的时候把newproducts表中的数据INSERT 到表products中
MERGE INTO products p USING newproducts np ON (p.product_id = np.product_id) WHEN NOT MATCHED THEN INSERT VALUES (np.product_id, np.product_name, np.category);
阅读全文
0 0
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- oracle 中 merge into 的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle 中 merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- Oracle中merge into的使用
- 跳转应用市场 评分等
- 基于c++11泛型编程开发一个LeetCode本地开发测试组件
- 前端设计--HTML,CSS
- 2017/6/29
- springMVC controller间跳转 重定向 传递参数的方法
- Oracle中merge into的使用
- 【C++】类和对象--基础知识+四个默认成员函数+运算符重载
- 源代码文件的扩展名:
- Linux下Vue开发环境搭建一篇全搞定
- Android界面布局文字水印
- tomcat catalina.out 乱码
- PHP通过URL传参的两种方式
- 单例模式
- 一张图读懂极大极小搜索和α-β剪枝