测试目的:
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
-------------------------------------
结论:
如果数据量比较大的话,还是尽量采用先倒入数据,后进行约束建立的方式进行;
阅读(1067) | 评论(0) | 转发(0) |