根据Oracle的文档的描述,数据泵采用不同的方式导出导入,性能也会有明显的差别,这次正好有机会测试一下,迁移表空间、直接路径、外部表方式,以及数据库链方式导出、导入的性能差异。
这篇测试外部表导出、导入方式。
首先清除上一篇文章中导入的用户和表空间,并重新建立测试用户和表空间。
SQL> DROP USER TJSQ_NDMAIN CASCADE;
User dropped.
SQL> DROP USER TJSQ_TRADE CASCADE;
User dropped.
SQL> DROP USER TJSQ_GOV CASCADE;
User dropped.
SQL> DROP USER TJSQ_NDMAIN_OPER CASCADE;
User dropped.
SQL> DROP USER TJSQ_TRADE_OPER CASCADE;
User dropped.
SQL> DROP TABLESPACE TJSQ INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL> DROP TABLESPACE TJSQ_TMP INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
下面重新创建用户,并设置权限:
SQL> CREATE USER TJSQ_NDMAIN IDENTIFIED BY TJSQ_NDMAIN;
User created.
SQL> CREATE USER TJSQ_TRADE IDENTIFIED BY TJSQ_TRADE;
User created.
SQL> CREATE USER TJSQ_GOV IDENTIFIED BY TJSQ_GOV;
User created.
SQL> CREATE USER TJSQ_NDMAIN_OPER IDENTIFIED BY TJSQ_NDMAIN_OPER;
User created.
SQL> CREATE USER TJSQ_TRADE_OPER IDENTIFIED BY TJSQ_TRADE_OPER;
User created.
SQL> GRANT CONNECT TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_TRADE_OPER;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_TRADE_OPER;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT CREATE DATABASE LINK TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_TRADE_OPER;
Grant succeeded.
表空间的建立以及数据文件初始化的时间需要单独计时:
SQL> SET TIMING ON
SQL> CREATE TABLESPACE TJSQ DATAFILE '/data/oracle/oradata/tjsq/tjsq01.dbf' size20g,
2 '/data/oracle/oradata/tjsq/tjsq02.dbf' size4g;
Tablespace created.
Elapsed: 00:02:07.68
SQL> CREATE TABLESPACE TJSQ_TMP DATAFILE '/data/oracle/oradata/tjsq/tjsq_tmp.dbf' size4g;
Tablespace created.
Elapsed: 00:00:22.19
这个步骤总用时2分30秒。
显然执行外部表方式的导出,由于Oracle默认采用直接路径的方式,因此要改变这种默认的设置,就必须做一些改动。
对于导出而言,如果需要外部表方式对所有的表都适用,最好的方法就是使用QUERY方式导出,加上一个恒等的导出条件,将使得导出不在使用直接路径方式: