根据Oracle的文档的描述,数据泵采用不同的方式导出导入,性能也会有明显的差别,这次正好有机会测试一下,迁移表空间、直接路径、外部表方式,以及数据库链方式导出、导入的性能差异。
这篇测试NETWORK_LINK导入方式。
首先清除上一篇文章中导入的用户和表空间,并重新建立测试用户和表空间。
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数据泵的默认导出、导入都是直接路径方式,因此当前的测试不需要进行额外的设置。
使用NETWORK_LINK方式执行导入是否的简单,不需要导出和传送的过程,只需要一个impdp命令就可以完成所有的操作: