table_a   a b c
          1 2 3
          4 5 6table_b   a b c d
          7 8 9 0怎么把 table_a 里的数据插入到 table_b 里

解决方案 »

  1.   


    insert into table_b
    select a.a,a.b,a.c,0
    from table_a a
      

  2.   


    SQL> with ta as(
      2       select 1 a,2 b,3 c from dual union all
      3       select 4,5,6 from dual)
      4  select a,b,c,0 d
      5  from ta
      6  /
     
             A          B          C          D
    ---------- ---------- ---------- ----------
             1          2          3          0
             4          5          6          0
      

  3.   

    什么叫没有足够的值,我都不知道你的数据是怎么来的:
    table_a 
      a b c
      1 2 3
      4 5 6table_b 
      a b c d
      7 8 9 0
    能告诉大家,你的数据怎么来的吗?
    或者经过什么计算得到的......
      

  4.   


    SQL> create table table_a(a number primary key,b number,c number);
     
    Table created
     
    SQL> create table table_b(a number primary key,b number,c number,d number);
     
    Table created
     
    SQL> insert into table_a values(1,2,3);
     
    1 row inserted
     
    SQL> insert into table_a values(4,5,6);
     
    1 row inserted
     
    SQL> commit;
     
    Commit complete
     
    SQL> insert into table_b values(7,8,9,0);
     
    1 row inserted
     
    SQL> commit;
     
    Commit complete
     
    SQL> select * from table_a;
     
             A          B          C
    ---------- ---------- ----------
             1          2          3
             4          5          6
     
    SQL> select * from table_b;
     
             A          B          C          D
    ---------- ---------- ---------- ----------
             7          8          9          0
     
    SQL> insert into table_b(a,b,c) select * from table_a;
     
    2 rows inserted
     
    SQL> commit;
     
    Commit complete
     
    SQL> select * from table_b;
     
             A          B          C          D
    ---------- ---------- ---------- ----------
             7          8          9          0
             1          2          3 
             4          5          6 
      

  5.   

    insert into a (a,b,c) select a,b,c from b ;