create table b as select *  from a where 条件

解决方案 »

  1.   

    insert into b(col1,col2..) select cola,colb.. from a where ...;是这个意思吗?
      

  2.   

    insert into b(col1,col2..) select cola,colb.. from a
      

  3.   

    如果不考虑删除数据与插入数据是否完全一致的情况,insert into b(col1,col2..) select cola,colb.. from a where ...;
    delete from a where ...;
    commit;即可。
      

  4.   

    你操作的过程是什么,查询->插入->?->删除?是什么
      

  5.   

    insert into b select * from a;
    commit;
    delete;
    commit;
      

  6.   

    我的工作流程是:查询-》插入-》删除
    插入完毕后,将使用查询使用的条件,删除数据;
    但是,使用insert into  ...  select 
    这样的语句,如果遇到了插入失败(记录重复),这样的情况下,系统会怎么处理?
    会自动放弃重复记录的插入,并继续其他记录的插入否?
      

  7.   

    放弃插入。
    重复记录应当在
    insert into ... select ...where not exists(select .. from B where b...=a...)(这个地方来控制)
      

  8.   

    insert into t2(tt)  select tt  from t1 where not exists(select b.tt from
    t1 a,t2 b where b.tt=a.tt);t1中的值为:
    1
    2
    5
    t2中的值为:
    1
    2执行以后,没有插入记录啊;
      

  9.   

    应该是:
    insert into t2(tt)  select tt  from t1 where not exists(select b.tt from t2 b where b.tt=a.tt);你原来的条件:select b.tt from t1 a,t2 b where b.tt=a.tt 永远为TRUE
      

  10.   

    用游标
    可以一条一条查出来,包含ROWID,全放到变量中,处理后INSERT进另一张表就行了
    删除时用ROWID做条件,又快又可靠
      

  11.   

    语句有问题
    insert into t2(tt)  select tt  from t1 
    where not exists(select 1 from
    t1 a where b.tt=a.tt);
      

  12.   

    如果是要更新主键相同的数据,可以在插入之前,先用命令把重复的数据在B中删除,再插入。
    如果有重复数据可用bzszp(SongZip)说的
    insert into ... select ...where not exists(select .. from B where b...=a...)
      

  13.   

    insert into t2 (select * from t1 minus select * from t2);commit work;可以用这个语句搞定minus这语句才是关键的
    但是怀疑速度慢t1里面的数据是有百W级的
      

  14.   

    昨天看了一晚上书,深刻的认识到SQL语句,也是个大大的学问啊;感触良多。。
    改帖建议放到精华区;