`
Fred_Han
  • 浏览: 144330 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

oracle 大表复制

阅读更多

常用的大表复制技术

传统方法 建表然后insert into
create table CLW_TEMP1 (  DX_PROCESS_NO VARCHAR2(15),TELE_NUM  VARCHAR2(11),OPER_CODE VARCHAR2(10),
DEPT_CODE VARCHAR2(8),DO_DEPT_CODE VARCHAR2(8),PLAN_ID NUMBER(8),ICC_ID  VARCHAR2(25),PROCESS_DATE  DATE);
insert into clw_temp1  select * from   clw_Temp;
执行时间  56.891s 
优化后的传统方法
   Create table  as …
CTAS的方法速度快是因为减少I/O
drop table clw_temp1;
create table clw_Temp1 as select * from clw_temp;    
74.922
CTAS UNRECOVERABLE
UNRECOVERABLE 能减半建表的时间,同时能够减少资源占用 因为它可以越过redo log processing. drop table clw_temp1;
    create table clw_Temp1 unrecoverable  as select * from clw_temp;    
    26.531
   CTAS PARALLEL
 并行访问并不是degree越大越好的,下面的例子已经说明了这个问题 具体值和硬件和软件平台都有关系 也和oracle初始设置有关  
 PARALLEL_MIN_SERVERS    PARALLEL_MAX_SERVERS
 PARALLEL_AUTOMATIC_TUNING = TRUE
drop table clw_temp1;
create table clw_Temp1 parallel (degree 4)   as select * from clw_temp;
49.797
drop table clw_temp1;
create table clw_Temp1 parallel (degree 2)   as select * from clw_temp;
36.359    APPEND
Append 提示告诉Oracle 使用快速机制来插入数据,和nologging会有更好的效果
If a table or an index is specified with nologging, this hint applied
with an insert statement produces a direct path insert which reduces generation of redo.  
insert /*+APPEND  */ into clw_temp1   select * from clw_temp;
44.687
NOLOGGING
在归档的模式下是有用的 drop table clw_temp1;
create table clw_Temp1 as  select * from clw_temp;    
45.047
综合使用各种提示优化
Create table clw_temp1 as select * from clw_temp1 where rownum<1 nologging;

insert /*+APPEND  parallel (degree 2)   */ into clw_temp1   select * from clw_temp 

38.922
从这里看出append 和nologging和parallel结合使用对效果提高是蛮大的
create table CLW_TEMP1 unrecoverable
 parallel (degree 2)  as select  * from clw_temp nologging 
 14.797 
看看用时14.797 堪称经典,与普通方法的执行时间相比,简直是天壤之别  

导入导出技术
可以使用Oracle IMP/EMP

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics