Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130446
  • 博文数量: 16
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-15 10:25
文章分类

全部博文(16)

文章存档

2010年(16)

我的朋友

分类: Oracle

2010-01-04 23:03:04

测试目的:

    1 建立一个表(无约束),然后导入数据,建立约束
    2 建立一个表(有约束),导入数据
    3 比较速度

实验:


    create table t_objects
    as
    select * from dba_objects
    where 1 = 2;

    ------------
    insert into t_objects
    select * from dba_objects
    where object_id is not null;

    --已用时间:  00: 00: 01.90
    ---
    alter table t_objects add constraint pk_t_objects primary key( object_id);

    --已用时间:  00: 00: 00.50
    ----共用去:  00:00:02.40
    -------------
    alter table t_objects drop constraint pk_t_objects;
    --已用时间:  00: 00: 00.14
    truncate table t_objects;

    --已用时间:  00: 00: 02.12
    --

    alter table t_objects add constraint pk_t_objects primary key( object_id);
    --已用时间:  00: 00: 00.03
    insert into t_objects
    select * from dba_objects
    where object_id is not null;
    --已用时间:  00: 00: 02.46
    ----共用去:  00:00:02:49
    -------------------------------------

结论:

   如果数据量比较大的话,还是尽量采用先倒入数据,后进行约束建立的方式进行;

阅读(1056) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~