From the course: Oracle Database 19c: Advanced SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

MERGE statement overview

MERGE statement overview - Oracle Database Tutorial

From the course: Oracle Database 19c: Advanced SQL

Start my 1-month free trial

MERGE statement overview

- [Lecturer] The merge statement is one-stop shopping for all of your data manipulation language needs. It can combine all three of the DML statements you use quite often; insert, update and DELETE, or two out of three of those are even just one. Here's the general format of the merge statement. As with any DML statement, you specify the table you wish to update, insert into or delete from. The source of the merge can be a subquery or just a plain table. For example, if you want to merge the contents of two tables into the destination table. When rows match using the on clause it's actually doing a join between the two row sets. You have to use either matched or not matched. Within the matched clause, you do an update with an optional delete. And if you're only using merge as a complex insert, you can have just the not matched clause. You don't have to have a where clause since you're doing all the filtering in the on clause But the delete section of merge must have a where clause…

Contents