insert into t1  (c1, c2, c3, c4 , c5, c6) 
select t2.c1, t2.c2, t2.c3, t2.c4 , t2.c5 , sysdate from t2,t1
where t1.c1=t2.c1
and t1.c2=t2.c2
and t1.c3=t2.c3
and c1 || c2 < to_char(sysdate,'YYYYMM') 

解决方案 »

  1.   

    insert into t1  (c1, c2, c3, c4 , c5, c6) 
    select t2.c1, t2.c2, t2.c3, t2.c4 , t2.c5 , sysdate from t2,t1
    where t1.c1=t2.c1
    and t1.c2=t2.c2
    and t1.c3=t2.c3
    and t2.c1 || t2.c2 < to_char(sysdate,'YYYYMM')
      

  2.   

    Sorry,弄錯了需求,不知道下面得行不行︰
    insert into t1  (c1, c2, c3, c4 , c5, c6) 
    (select c1, c2, c3, c4 , c5 , sysdate from t2where t2.c1 || t2.c2 < to_char(sysdate,'YYYYMM')minusselect t2.c1, t2.c2, t2.c3, t2.c4 , t2.c5 , sysdate from t2,t1
    where t1.c1=t2.c1
    and t1.c2=t2.c2
    and t1.c3=t2.c3
    and t2.c1 || t2.c2 < to_char(sysdate,'YYYYMM')
    )
      

  3.   

    谢谢帮忙,不过我是问为什么同一个sql语句在不同的机器上执行时间相差很大,不是优化sql语句