环境背景:
本地 :IP:127.0.0.1 端口:1521 实例:orcl 用户:local_sys/123
远程服务器:IP:192.168.0.100端口:1521 实例:orcl 用户:server_sys/123
目标:将服务器上server_user1用户导出到本地
1.登录本地数据库
C:\Users\admin>sqlplus / as sysdba
2.创建dblink
语句:
create database link DBLINK_NAME connect to system identified by orcl using 'TNS_NAME';
示例:
create database link local_to_server connect to system identified by orcl using 'TO_SERVER;
说明:DBLINK_NAME 是自己为dblink命名,TNS_NAME是已配置的TNS名,此处示例的TNS配置为:
TO_SERVER= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
创建完成后执行语句:
select * from dual@local_to_server;
结果:x
表示创建成功,如果遇到问题,请参考:http://www.jb51.cc/article/p-ukiruhkn-kq.html
3.创建数据库目录
语句:
create directory MY_DIR as 'd:\dump';
授权:
grant write,read on directory MY_DIR to local_sys;
创建完成后执行语句:
select * from dba_directories;查看创建结果
4.导出
语句:
expdp local_sys/123@127.0.0.1:1521/orcl network_link=local_to_server directory=MY_DIR dumpfile=result.dmp logfile=result.log SCHEMAS=server_user1
注意,此语句在dos窗口直接执行,执行完成后检查d:\dump有没有result.dmp和result.log文件,result.dmp为目标文件,result.log为日志文件
参考文章:
原文链接:https://www.f2er.com/oracle/209809.html