oracle 远程导入导出dmp文件

--进入sqlplus,先建立一个目录用来dump数据库
create directory dump_test as 'F:\xuyi\dump'  ;

--查看一下是否存在该目录
select * from dba_directories;

--授权给操作用户这个dump目录的权限
grant read, write on directory dump_test to xuyi;

--PS:下面是在命令行执行而不是在sqlplus,而且注意如果版本不一致请注明对方版本,如不注明schemas的话则默认导出登陆用户的数据

--导出:不能带分号结尾(Linux中需要切换到Oracle用户才能执行:su - oracle)
expdp xuyi/password@dbName schemas=db_user  directory=dump_test dumpfile=data.dmp  version=11.1.0.6.0 

--导入:不能带分号结尾
impdp xuyi/password@dbName directory=dump_test dumpfile=data.dmp

--想远程导入请使用NETWORK_LINK参数指定DB LINK,关于如何设置请参照如下文档:

--http://wenku.baidu.com/view/b67bfa06e87101f69e31953a.html

--xuyi是远程服务名
create database link link5 connect to scott identified by tiger using 'xuyi';
--查看是否生效
select * from global_name@link5;
--xuyi/password为本地账号密码,而link5中包含远程服务器账号密码
expdp xuyi/password network_link=link5 schemas=scott  directory=dump_test dumpfile=data.dmp
 

PS:如果expdp需要从高版本导出到低版本 必须在高版本上加上version=低版本号 这样低版本才能识别高版本的dmp文件

也有可能权限会有问题,如下:

 

在利用NETWORK_LINK方式导出的时候,出现了这个错误。
详细错误信息如下:
bash-3.00$ expdp yangtk/yangtk directory=d_temp dumpfile=jiangsu.dp network_link=test113 logfile=jiangsu.log tables=cat_org
Export: Release11.1.0.6.0 - 64bit Production on星期二, 16 9月, 2008 17:08:22
Copyright (c) 2003, 2007, Oracle.  All rights reserved.
连接到: Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-31631:需要权限
ORA-39149:无法将授权用户链接到非授权用户
检查Oracle的错误手册:
ORA-39149: cannot link privileged user to non-privileged user
Cause: A Data Pump job initiated be a user with EXPORT_FULL_DATABASE/IMPORT_FULL_DATABASE roles specified a network link that did not correspond to a user with equivalent roles on the remote database.
Action: Specify a network link that maps users to identically privileged users in the remote database.
错误描述的比较清楚,不过这个错误很难理解,难道一个权限大的用户不能通过数据库链导出一个权限小的用户。
当然,了解了这个错误的原因,其实问题很容易解决。在本地创建一个新用户,不要授权EXP_FULL_DATABASE/IMP_FULL_DATABASE角色,就可以导出:
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release11.1.0.6.0 - Production on星期二9月16 16:53:48 2008
Copyright (c) 1982, 2007, Oracle.  All rights reserved.

连接到:
Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> col grantee format a15
SQL> col granted_role format a15
SQL> select grantee, granted_role from dba_role_privs
  2  where grantee = 'YANGTK';
GRANTEE         GRANTED_ROLE
--------------- ---------------
YANGTK          CONNECT
YANGTK          RESOURCE
YANGTK          DBA
SQL> drop user test cascade;
用户已删除。
SQL> create user test identified by test
  2  default tablespace users
  3  quota unlimited on users;
用户已创建。
SQL> grant connect to test;
授权成功。
SQL> grant create table, create database link to test;
授权成功。
SQL> grant read, write on directory d_temp to test;
授权成功。
SQL> conn test/test
已连接。
SQL> create database link test113 connect tojiangsuidentified byjiangsu
  2  using '172.0.2.113/test';
数据库链接已创建。
SQL> select * from global_name@test113;
GLOBAL_NAME
--------------------------------------------------------------------------------
TEST
SQL> exit


 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值