使用expdp和impdp远程导入导出库

使用expdb ,impdp 导入导出库,首先在本地必须建立db_link才可导入导出,exp,imp 这两个命令无需建立db_link即可导入导出。

一.远程导出库的步骤:

1.在本地库的配置文件中加如下配置:

tnames.ora增加
[html]  view plain  copy
  1. orcl =  
  2.   (DESCRIPTION =  
  3.     (ADDRESS_LIST =  
  4.       (ADDRESS = (PROTOCOL = TCP)(HOST = 远程主机IP)(PORT = 1521))  
  5.     )  
  6.     (CONNECT_DATA =  
  7.       (SERVICE_NAME = 远程服务名)  
  8.     )  
  9.   )  


 

2.创建dblink

[html]  view plain  copy
  1. SQL>  create public database link oradb(db_link名)connect to userneme(远程登录用户名) identified by password(远程数据库用户密码) using 'oradb';  
  2.   
  3. Database link created.  
  4.   
  5. SQL> select * from test.db@oradb;  
  6.   
  7.      ID NAME  
  8. ---------- --------------------  
  9.      1 zhangsan  
  10.      2 lisi 


 

3.创建导出临时目录:

[html]  view plain  copy
  1. SQL> create or replace directory dumpdir as '/oradata/dump';  
  2.   
  3. Directory created.  


 

4.授权用户,一般用system用户。

[html]  view plain  copy
  1. SQL> grant read,write on directory dumpdir to hr;  
  2.   
  3. Grant succeeded.  
  4.   
  5. SQL> conn zhangsan/zhangsan  
  6. Connected.  
  7. SQL> select * from test.db@oradb;  
  8.   
  9.      ID NAME  
  10. ---------- --------------------  
  11.      1 zhangsan  
  12.      2 lisi  
  13.      1 wangwu  
  14.   
  15. SQL> quit  


 

5.在cmd中写expdp 导出语句:

 
[html]  view plain  copy
  1. [oracle@ORA11G-DG1 ~]$ expdp 本地登录库的用户名密码(system/orcl)  network_link=oradb directory=dumpdir dumpfile=test.dmp logfile=test.log schemas=test  
  2.   
  3. (1):问题1:  
  4. Export: Release 11.2.0.4.0 - Production on Wed Dec 10 07:50:25 2014  
  5.   
  6. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  
  7.   
  8. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production  
  9. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  10. ORA-31631: privileges are required  
  11. ORA-39109: Unprivileged users may not operate upon other users' schemas  
  12.    
  13. 问题解决办法  
  14. SQL*Plus: Release 11.2.0.4.0 Production on Wed Dec 10 07:52:01 2014  
  15.   
  16. Copyright (c) 1982, 2013, Oracle.  All rights reserved.  
  17.   
  18.   
  19. Connected to:  
  20. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production  
  21. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  22.   
  23. SQL> grant exp_full_database  to zhangsan;  
  24.   
  25. Grant succeeded.  
  26.   
  27. SQL> quit  
  28.    
  29. (2):问题2:  
  30. ORA-31631: privileges are required  
  31. ORA-39149: cannot link privileged user to non-privileged user  
  32.    
  33. 解决办法  
  34. 连接到:  
  35. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production  
  36. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  37.   
  38. SQL> grant exp_full_database to test;  
  39.   
  40. 授权成功。  


以上是导出步骤。

二.远程导入库:

1.步骤请参照导出库。
2.直接写导入语句:

[html]  view plain  copy
  1. Impdp  utest/utest@orcl  directory=DMPDIR  schemas=e01   network_link=sourcedatabase remap_schema=e01:e0311  job_name=impjob   
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值