t1,t2的主键为f1,f2,f3的组合
t1(f1,f2,f3,f4)
t2(f1,f2,f3,f4,f5)insert into t1(f1,f2,f3) 
select f1,f2,f3 from t2 where f1+f2+f3 not in(select f1+f2+f3 from t1);
oracle中如何实现,把表t2(t1中没有的)中的f1,f2,f3插入到t1表中。。
即“f1+f2+f3 not in(select f1+f2+f3 from t1)”这部分要如何写?

解决方案 »

  1.   

    insert into t1(f1,f2,f3) 
    select f1,f2,f3 from t2 where f1,f2,f3 not in(select f1,f2,f3 from t1);
    insert into t1(f1,f2,f3) 
    select f1,f2,f3 from t2 where (f1,f2,f3) not in(select f1,f2,f3 from t1);晕,,好像就差一括号。
      

  2.   

    原搬你的意思的话,应该是这样
    insert into t1(f1,f2,f3) 
    select f1,f2,f3 from t2 where f1||f2||f3 not in(select f1||f2||f3 from t1);但这样写是有漏洞的