六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 279|回复: 0

使用expdp/impdp远程导入导出oracle数据

[复制链接]

升级  97.2%

314

主题

314

主题

314

主题

进士

Rank: 4

积分
986
 楼主| 发表于 2013-1-29 15:28:42 | 显示全部楼层 |阅读模式
--进入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_orgExport: Release11.1.0.6.0 - 64bit Production on星期二, 16 9月, 2008 17:08:22Copyright (c) 2003, 2007, Oracle.  All rights reserved.连接到: Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsORA-31631:需要权限ORA-39149:无法将授权用户链接到非授权用户检查Oracle的错误手册:ORA-39149: cannot link privileged user to non-privileged userCause: 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 2008Copyright (c) 1982, 2007, Oracle.  All rights reserved.连接到:Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> col grantee format a15SQL> col granted_role format a15SQL> select grantee, granted_role from dba_role_privs  2  where grantee = 'YANGTK';GRANTEE         GRANTED_ROLE--------------- ---------------YANGTK          CONNECTYANGTK          RESOURCEYANGTK          DBASQL> 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--------------------------------------------------------------------------------TESTSQL> exit
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表