oracle表a中需要插入与其表格式完全想同的表b.表a7000w数据,表b600w.
试过
alter table a nologging;
insert/*+append*/ into a select * from b;
commit;
alter table a logging;
但是这样的话插入数据还是太慢,两个钟头都没倒进去.中途中断以后表a没有新数据插入.请问有没有好的办法?
请教一二.或者是我写的有问题.
  

解决方案 »

  1.   

    可不可以分段插入?比如插入10W行后就commit一次?
      

  2.   

    600w的数据应该还好,你看下你的a表有没被锁住。不会要那么长时间。你这样试下看看
    create table a1 as
    select * from a
    union all
    select * from b;truncate table a;
    drop table a;rename a1 to a;
      

  3.   


    --你原表A上是不是有index,如果有闲drop掉再重建试试
    alter table a nologging
    drop index index_name        --先删除表上的index(若有),或者是禁掉!
    insert /*+append*/ into a select * from b;  --执行插入
    create index index_name on   --重建index
    alter table a logging
      

  4.   

    想过这个方法,
    create table a1 nologging as
    select * from a
    union  
    select * from b;那样的话涉及到a的表的触发器,主键,索引,甚至存储过程都得重建,怕漏了没敢试
      

  5.   

    那样的话sql语句写起来有点儿复杂了,呵呵.暂时没那么想
      

  6.   

    1、检查一下b表数据所占空间,确认b表所在表空间用足够的空间,
         如果不够,先扩充表空间,这样可避免表空间自动扩展太慢。
    2、手动为表分配extent,如:alter table allocate extent (size 10M);
    3、禁用a表中一切约束(主、外键等),删除a表相关索引。
    4、insert ...select....;
    5、启动表中约束,重建索引。
      

  7.   

    1禁用所有东西
    2:不行用IMP慢慢导入吧
      

  8.   

    手动为表分配extent,如:alter table allocate extent (size 10M);
    这句话有什么好处?
    跟 alter tablespace users add datafile '' size 100m autoextend on next 10m maxsize unlimited;效果相同吗?有啥区别?
      

  9.   

    手动分配一步到位分配更多的空间,避免oracle采用循环来分配空间,效率要高一些。
      

  10.   

    b表有没有什么规律?  比如说  一个条件可以过滤出一部分 (几万条数据)?,
    insert/*+append*/ into a select * from b where b.flag=?;
    写一个循环语句。 估计可以提升效率。
    否则,回滚段占用太大了。