Wednesday, July 16, 2014

MERGE Statement in Oracle SQL

Following MERGE statement is used to search the record in the file, If the record exist then update statement will run and if the record is not found then insert statement will run.


In below example Employee number is the key, Both files are join on employee number. If the employee exist then update the name , job and salary of the employee and if the employee is not exist then insert all fields from EMP table into COPY_EMP table.


SELECT * FROM COPY_EMP;







STATEMENT:













RESULT:




















No comments:

Post a Comment