Oracle9i有这样的SQL语句,具体语法如下:merge into table_name as table_alias using (table/view/sub_query) as alias on (join condition) when matched then update set col1=col_val1, col2=col2_val when not matched then insert (column_list) values (column_values);
存在于A表上则更新,否则插入 merge into table1 a using(select * from table2 b) on (a.id=b.id) when matched then update set fno='old' when not matched then insert into values(a.id,'new');参考: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#SQLRF01606
using (table/view/sub_query) as alias
on (join condition)
when matched then
update set col1=col_val1,
col2=col2_val
when not matched then
insert (column_list)
values (column_values);
merge into table1 a
using(select * from table2 b)
on (a.id=b.id)
when matched then
update set fno='old'
when not matched then
insert into values(a.id,'new');参考:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#SQLRF01606