Search code examples
sqloracle-databaseora-00001

In Oracle, can I do an "insert or update values into TABLE"


I have a table with two number columns, and a unique constraint over them both. I would like to insert a new pair of values UNLESS the pair already exists. What is the simplest way to do this?

If I do

insert into TABLE values (100,200) 

and the pair already exists I get a ORA-00001 error, so I would like to do something like

insert or update into TABLE values (100,200)

Solution

  • You can use MERGE