Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> INSERT, UPDATE
Somebody could show me how to INSERT new rows from tab2 to tab1
and UPDATE rows of tab1 with new values from tab2
Every day I replace values in tab2 with sql-loader (REPLACE option) ( tab2 is my "temporary table" )
structure of tab1 and tab 2 are identical :
ch1 VARCHAR2(5) ch2 VARCHAR2(5) ch3 VARCHAR2(10) ch4 VARCHAR2(3)
the primary key is (ch1, ch2, ch3, ch4)
i'd like to insert new rows into tab1 and i'd like to update rows with new values
to INSERT i found :
INSERT INTO tab1 ( ch1, ch2, ch3, ch4 )
SELECT ch1, ch2, ch3, ch4 FROM tab2 WHERE NOT EXISTS( SELECT ch1, ch2, ch3, ch4 FROM tab1 WHERE t1.ch1 = t2.ch1 AND t1.ch2 = t2.ch2 AND t1.ch3 = t2.ch3 AND t1.ch4 = t2.ch4 );
But to UPDATE i don't known well ... thanks to help me
Jean-Yves LE STRAT
mailto:jylestrat_at_comx.fr
![]() |
![]() |