insert ignore into table1
select 'value1',value2
from table2
where table2.type = 'ok'
When I run this I get the error "missing INTO keyword" .
Any ideas ?
insert ignore into table1
select 'value1',value2
from table2
where table2.type = 'ok'
When I run this I get the error "missing INTO keyword" .
Any ideas ?
Note that if you are lucky enough to work with version 11g Release 2, you can use the hint IGNORE_ROW_ON_DUPKEY_INDEX.
From the documentation: http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/sql_elements006.htm#CHDEGDDG
An example from my blog: http://rwijk.blogspot.com/2009/10/three-new-hints.html
Regards, Rob.
Because you typed the spurious word "ignore" between "insert" and "into"!!
Should be:
From your question title "oracle insert if row not exists" I assume you thought "ignore" was an Oracle keyword that means "don't try to insert a row if it already exists". Maybe this works in some other DBMS, but it doesn't in Oracle. You could use a MERGE statement, or check for existence like this:
Because IGNORE is not a keyword in Oracle. That is MySQL syntax.
What you can do is use MERGE.
From Oracle 10g we can use merge without handling both branches. In 9i we had to use a "dummy" MATCHED branch.
In more ancient versions the only options were either :