有两张表,table1和table2 ,table1中的大量的数据(上亿条的),table2是空表,我现在要将table1中的所有数据插到table2中,有木有什么方法可以提高速度的?求牛逼的sql语句。

解决方案 »

  1.   

    把table2删掉,直接用create table2 as select * from table1,如果机器够好,加并行!
      

  2.   

    1.insert into table2 select * from table1
    2.删除table2,直接用工具将table1生成table2.
      

  3.   

    晕死 没看到table2表已经存在了吗 而且结构是一样的。。
      

  4.   

    wf@WF>select * from tab;TNAME                          TABTYPE  CLUSTERID
    ------------------------------ ------- ----------
    BIN$j/G6GzuWTciCfbYqWKWPsg==$0 TABLE
    DUALD                          TABLE已用时间:  00: 00: 00.12
    wf@WF>create table t1(i int);表已创建。已用时间:  00: 00: 00.39
    wf@WF>alter table t1 rename t2;
    alter table t1 rename t2
                          *
    第 1 行出现错误:
    ORA-14155: 缺失 PARTITION 或 SUBPARTITION 关键字
    已用时间:  00: 00: 00.07
    wf@WF>rename table t1 to t2;
    rename table t1 to t2
           *
    第 1 行出现错误:
    ORA-00903: 表名无效
    已用时间:  00: 00: 00.04
    wf@WF>rename t1 to t2;表已重命名。已用时间:  00: 00: 00.15
    wf@WF>select * from tab;TNAME                          TABTYPE  CLUSTERID
    ------------------------------ ------- ----------
    BIN$j/G6GzuWTciCfbYqWKWPsg==$0 TABLE
    DUALD                          TABLE
    T2                             TABLE已用时间:  00: 00: 00.00
    wf@WF>
      

  5.   

    表结构是一样的?drop table table2;alter table table1 rename to table2;
      

  6.   

    囧,忘记了。 table1,还要的是吧。--这样呢?
    insert /*+ append */ into table2 nologging
    select * from table1;