比如表A  有YEAR等字段
50万条左右。现在由于数据过多每次反问此表效率过低。
我想按YEAR来拆分2009年的一个表2008年的一个 等等。如何高效率完成?
   

解决方案 »

  1.   

    建个YEAR 这个字段的索引,然后根据year=2009 或者=2008 来区分年份
      

  2.   

    create table tb2009 as select * from a where year=2009;
    create table tb2008 as select * from a where year=2008;
    --或者先建好两个表再insert直接装载
    --创建表只需要表结构
    create table tb2009 as select * from a where 1=2;
    insert /*+append*/ into tb2009 select * from a where year=2009;
      

  3.   

    写个匿名块,循环操作.
    表名形式 固定前缀+年份.
    使用动态sql.execute immediate 来执行create table as
      

  4.   

    楼上说的都不错!可以参考!动态sql是比较省事,但是速度上不一定快的!