如何将查询后的记录存入另外一张表中

解决方案 »

  1.   

    insert into tb
    select * from ta
      

  2.   

    同时生成tb新表
    select * 
    into tb
    from ta
      

  3.   

    insert into tb2 select * from tb2
      

  4.   

    INSERT TB SELECT * FROM TA --TB EXISTS
    SELECT * INTO TB FROM TA --TB NOT EXISTS
      

  5.   

    --表不存在
    select * into tb2 from tb1--表存在
    insert into tb2 select * from tb1
      

  6.   

    --新表不存在
    select * 
    into 新表 
    from 旧表
    where 查询条件--新表不存在
    insert into 新表 
    select *
    from 旧表
    where 查询条件
      

  7.   

    如果需要子查询.--表不存在
    select col into tb2 from (select * from tb1) t  --表存在
    insert into tb2 select col from (select * from tb1) t
      

  8.   


    --表不存在
    select * into newtable from tb
    --表已存在
    insert newtable(字段列表) select 字段列表 from tb