expdp的network_link参数的使用

expdpnetwork_link 参数的使用

expdpserver 端工具,但可以通过NETWORK_LINK 参数实现远端导出,但是前提是远端也安装有Oracle 数据库,只有CLIENT 端是没有办法利用数据泵的。

这里要指出的是:network_link 不支持远端导出分区表中的某一个分区,但可以导整个分区表。以下为测试过程:

创建分区表sales

[oracle@ora10g ~]$ sqlplus ‘/as sysdba’

SQL> CREATE TABLE sales

(sale_date DATE NOT NULL)

PARTITION BY RANGE (sale_date)

(PARTITION sales2010_q1

VALUES LESS THAN (TO_DATE(’2010-04-01′,’YYYY-MM-DD’))

TABLESPACE sp1,

PARTITION sales2010_q2

VALUES LESS THAN (TO_DATE(’2010-07-01′,’YYYY-MM-DD’))

TABLESPACE sp2,

PARTITION sales2010_q3

VALUES LESS THAN (TO_DATE(’2010-10-01′,’YYYY-MM-DD’))

TABLESPACE sp3);

插入4 条记录:

SQL> select count(*) from sales;

COUNT(*)

———-

4

SQL> select * from sales partition(sales2010_q1);

SALE_DATE

————

23-MAR-10

SQL> select * from sales partition(sales2010_q2);

SALE_DATE

————

23-JUN-10

22-JUN-10

SQL> select * from sales partition(sales2010_q3);

SALE_DATE

————

23-SEP-10

远端机器上创建 directory 目录、赋权、创建dblink:

[oracle@node1 /]$ sqlplus ‘/as sysdba’

SQL> create directory dump_dir as ‘/backup’;

Directory created.

SQL> grant read,write on directory dump_dir to ochef;

Grant succeeded.

SQL> create database link test connect to ochef identified by oracle using ‘primary’;

Database link created.

SQL> select count(*) from ochef.sales@test;

COUNT(*)

———-

4

远程导出整个分区表:

[oracle@node1 ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options

Starting “OCHEF”.”SYS_EXPORT_TABLE_01″:  ochef/******** directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales

Estimate in progress using BLOCKS method…

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 384 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

. . exported “OCHEF”.”SALES”                             4.960 KB       4 rows

Master table “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully loaded/unloaded

******************************************************************************

Dump file set for OCHEF.SYS_EXPORT_TABLE_01 is:

/backup/sales.dmp

Job “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully completed at 11:12:43

远程导出分区表的某个分区:

[oracle@node1 ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales:sales2010_q2

ORA-39001: invalid argument value

ORA-39203: Partition selection is not supported over a network link.

本地导出分区表的某个分区:

[oracle@ora10g ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp tables=sales:sales2010_q2

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “OCHEF”.”SYS_EXPORT_TABLE_01″:  ochef/******** directory=dump_dir dumpfile=sales.dmp tables=sales:sales2010_q2

Estimate in progress using BLOCKS method…

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 128 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

. . exported “OCHEF”.”SALES”:”SALES2010_Q2″              4.937 KB       2 rows

Master table “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully loaded/unloaded

******************************************************************************

Dump file set for OCHEF.SYS_EXPORT_TABLE_01 is:

/backup/sales.dmp

Job “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully completed at 11:07:07

 

expdp 属于服务端工具,而exp 属于客户端工具 expdp 生成的文件默认是存放在服务端的,而exp 生成的文件是存放在客户端的

1.expdp username/password @connect_string    // 对于使用这种格式来说,directory 使用源数据库创建的, 生成的文件存放在服务端

 

比如服务端数据库为linux ,当前客户端为windows 下,我在windowsexpdp linux 里的数据

expdp username/password@sidname directory=data_dump dumpfile=downip.dmp

其中directory=data_dump  是在服务端创建的directory

执行提示如下:

连接到 : Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SEAR_IC"."SYS_EXPORT_SCHEMA_01":  sear_ic/********@pdf directory=data_dump dumpfile=downip.dmp
Estimate in progress using BLOCKS method…
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 468.1 MB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
。。。。。
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SEAR_IC"."DATASHEET"                       389.3 MB 2929103 rows
。。。。。。

. . exported "SEAR_IC"."URL_TYPE"                        5.320 KB       6 rows
Master table "SEAR_IC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEAR_IC.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/downip.dmp
Job "SEAR_IC"."SYS_EXPORT_SCHEMA_01" successfully completed at 16:56:43

执行速度非常的快,跟在服务器端执行的速度差不多

如何 将生成的文件放在目标数据库 而不放在源数据库呢, expdp 中使用network_link
2.
a.
创建到服务端的dblink

conn aa/aacc
create database link link_name connect to  username identified by password using 'connect_string' ;//username
passwordserver 端的
b.

conn / as sysdba
create or replace directory dir as 'directory';
grant read,write on directory dir to username;

c.expdp username2/password2  directory=dir network_link=link_name …  //这里的username2 创建dblink 的那个用户aa directory 也是目标数据库创建的

 

比如在本机expdp 远程服务器的数据库,先在本机创建到服务端的dblink ,然后创建directory 及授权,然后expdp useranme2/password2 network_link=link_name directory=dir dumpfile=dump_filename.dmp tables=tab_name  这样就会在当前机器上(目标数据库)上产生一个dmp 文件


 

3. 如果想不生成dmp 文件而直接导入一个数据库,原理和2 类似,直接使用impdpnetwork_link ,这样可以直接impdp ,而绕过了expdp 的步骤

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值