MERGE Statement in SQL Explained


MERGE Statement in SQL Explained

Prerequisite – MERGE Statement 
As MERGE statement in SQL, as discussed before in the previous post, is the combination of three INSERT, DELETE and UPDATE statements. So if there is a Source table and a Target table that are to be merged, then with the help of MERGE statement, all the three operations (INSERT, UPDATE, DELETE) can be performed at once.

A simple example will clarify the use of MERGE Statement.

Example:
Suppose there are two tables: 

  • PRODUCT_LIST which is the table that contains the current details about the products available with fields P_ID, P_NAME, and P_PRICE corresponding to the ID, name and price of each product.
  • UPDATED_LIST which is the table that contains the new details about the products available with fields P_ID, P_NAME, and P_PRICE corresponding to the ID, name and price of each product.

 

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/database/278457.html

(0)
上一篇 2022年8月2日 17:18
下一篇 2022年8月2日 17:18

相关推荐

发表回复

登录后才能评论