表1:test1
列mm (varchar2)
233
23
56
df
3表2:test2 
列mm (number)表3:test3
列mm (varchar2)如何把test1的数据插进test2,插不进的就插进test3?
原表不止一列,且每天有500万数据要作这样的分离。请各位大虾说一下可行的方法
insert into test2 select from test1 一条数据都插不进,因为发现数据里有无法转换成number的行。

解决方案 »

  1.   

    数值插入:
    insert into test2 
     (select t.mm from tab t
     where substr(t.mm,1)<'a'
     )字符插入:
    insert into test3 
     (select t.mm from tab t
     where substr(t.mm,1)>='a'
     )
      

  2.   

    SQL> declare cursor v_csr is select mm from test1 for update ;
      2  begin
      3  for y in v_csr loop
      4      begin
      5          insert into test2 values(y.mm);
      6      exception
      7      when others then
      8          insert into test3 values(y.mm);
      9      end;
     10  end loop;
     11      commit ;
     12  end ;
     13  /PL/SQL procedure successfully completedSQL> select * from test2;        MM
    ----------
           233
           233
            23
            56
             3SQL> select * from test3 ;MM
    ----------
    df
      

  3.   

    to:xiaoxiao1984(笨猫儿) 
    恭喜笨猫升了!星。