insert table1(a,b)
select a1,a2 from table2;上面的语句中,如果a2是long数据类型的话,这个语句执行起来就会报错了。不用游标,具体怎么才能把数据插入到table1中呢?

解决方案 »

  1.   

    insert table1(a,b)
    select a1, to_char(a2,'0000000000000') from table2; 
      

  2.   

    table1中的b字段是什么类型的?报什么错
      

  3.   

    long列是不允许出现在create table xx as select * from yyy里的
    In addition, LONG columns cannot appear in these parts of SQL statements:
    ....
    SELECT lists of CREATE TABLE ... AS SELECT statements
    .....
    oracle建议使用clob\blob\nclob来代替。
    如:
    create table t(a int,b long);
    insert into t values(1,'1');
    --可以这样创建,不过默认类型就成了clob
    create table t1 as select a,to_lob(b) from t;
    --也可以这样,先创建一个表,然后在插入数据时使用to_lob函数转换一下
    create table t2 (a int,b long);
    insert into t2 select a,to_lob(b) from t;
    见Oracle® Database SQL Reference的RAW and LONG RAW Datatypes