重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 702|回复: 0
打印 上一主题 下一主题

[Oracle] 数据泵(network_link)迁移远端数据库用户数据

[复制链接]
跳转到指定楼层
楼主
发表于 2025-5-25 15:18:11 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
一、源库创建scott用户测试数据
SQL> create table tt (id int);

Table created.

SQL> insert into tt values (100);

1 row created.

SQL> insert into tt values (200);

1 row created.

SQL> insert into tt values (300);

1 row created.

SQL> commit;

Commit complete.


二、源库创建测试用户test
SQL> create user test identified by "oracle#123" account unlock;

User created.

SQL> grant connect,resource to test;

Grant succeeded.

SQL> grant exp_full_database to test;

Grant succeeded.


三、目标库创建Scott用户
SQL> create user scott identified by oracle account unlock;

User created.

SQL> grant connect,resource to scott;

Grant succeeded.

SQL> alter user scott default tablespace test;

User altered.

SQL> alter user scott quota unlimited on test;

User altered.


四、目标库创建dblink
[oracle@19c01 admin]$ vi tnsnames.ora
ORCLTEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.162.130)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)


create public database link orcltest connect to test identified by "oracle#123" using
'(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.162.130)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)';






测试dblink
SQL> select * from scott.tt@to_orcl;

ID
----------
100
200
300

五、创建directory
create or replace directory dmpdir as '/home/oracle’;

六、迁移scott用户数据
[oracle@19c01 admin]$ impdp \'/ as sysdba \' directory=DMPDIR network_link=orcltest logfile=impdp_orcl_test.log tables=scott.tt

Import: Release 19.0.0.0.0 - Production on Fri May 23 18:57:18 2025
Version 19.16.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYS"."SYS_IMPORT_TABLE_01": "/******** AS SYSDBA" directory=DMPDIR network_link=orcltest logfile=impdp_orcl_test.log tables=scott.tt
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . imported "SCOTT"."TT" 3 rows
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Fri May 23 18:57:27 2025 elapsed 0 00:00:08

[oracle@19c01 admin]$

七、目标库验证测试数据
[oracle@19c01 admin]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 24 00:19:56 2025
Version 19.16.0.0.0

Copyright (c) 1982, 2022, Oracle. All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0

SQL> conn scott/oracle
Connected.
SQL> select * from tt;

ID
----------
100
200
300

SQL>



迁移完成。


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2026-5-1 23:00 , Processed in 0.229519 second(s), 22 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

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