How to upsert (update or insert into a table)?



How to upsert (update or insert into a table)?..

Answer / Manmeet Singh

Oracle doesn't have a built-in UPsert statement like some other databases. Instead, you can create a MERGE statement that performs an update if the record exists and an insert if it doesn't. Here is a basic example: `MERGE INTO EMPLOYEES t TARGET USING (SELECT * FROM another_table) s ON (t.employee_id = s.employee_id) WHEN MATCHED THEN UPDATE SET column1 = s.column1, column2 = s.column2 WHEN NOT MATCHED THEN INSERT (column1, column2) VALUES (s.column1, s.column2);`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

What are the different types of database objects?

1 Answers  


How to create an initialization parameter file?

1 Answers  


How do I limit the number of oracle database connections generated by weblogic server?

1 Answers  


Explain the characteristics of oracle dba?

1 Answers  


What types of joins are used in writing subqueries?

1 Answers  


What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?

1 Answers  


What is a cluster?

2 Answers  


What are the execution control statements?

1 Answers  


What is an oracle and why it is used?

1 Answers  


What is truncate oracle?

1 Answers  


1.how to extract the second highest salary from emp table having sal as a column which contains the salary of all employee of an organisation.

6 Answers  


what is the syntax of DROP command?

10 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1803)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)