【oracle】oracle基于数据泵方式进行数据迁移

下面以windows下oracle操作为例

1. 使用数据泵备份

  • 在D盘创建目录yn作为备份后的保存的的文件夹

  • 使用dba用户在oracle服务器上登录sqlplus sqlplus sys/sys@orcl as sysdba

  • 在sys登录后的sql命令行中创建导出目录对象create or replace directory exp_dir as 'D:\yn\';

  • 授权指定用户具有访问目录的权限

    sql 复制代码
    -- 授予目录读写权限
    grant read,write on directory exp_dir to test_user; 
    -- 授予数据泵操作权限
    grant exp_full_database to test_user;
    -- 预防用户权限不足
    grant dba to test_user; 
  • 导出操作(在服务器terminal中执行)

shell 复制代码
expdp test_user/test_user_pass@orcl 
 directory=exp_dir 
 dumpfile=exp_user_20260211.dmp 
 logfile=exp_user_20260211.log

命令中各字段说明如下

test_user:登录用户

test_user_pass:登录用户的密码

orcl:当前用户的 schema

exp_dir:前面设置的导出目录名称

dumpfile:导出的dmp文件名称

logfile:本次导出操作的日志

2. 使用数据泵还原

  • 在D盘创建目录yn作为导入时的保存数据的的文件夹,并将数据复制到这个文件夹下

  • 使用dba用户在oracle服务器上登录sqlplus sqlplus sys/sys@orcl as sysdba

  • 在sys登录后的sql命令行中创建导入目录对象create or replace directory imp_dir as 'D:\yn\';

  • 授权指定用户具有访问目录的权限

    sql 复制代码
    -- 授予目录读写权限
    grant read,write on directory imp_dir to test_user; 
    -- 授予数据泵操作权限
    grant imp_full_database to test_user;
    -- 预防用户权限不足
    grant dba to test_user; 
  • 导入操作(在服务器terminal中执行)

shell 复制代码
impdp test_user1/test_user_pass@orcl2 
 directory=imp_dir 
 dumpfile=exp_user_20260211.dmp 
 logfile=imp_user_20260211.log
 remap_schema=test_user:test_user1  
 remap_tablespace=orcl1:orcl2

命令中各字段说明如下

test_user1:登录用户

test_user_pass:登录用户的密码

orcl2:当前用户的 schema

imp_dir:前面设置的导入目录名称

dumpfile:待导入的dmp文件名称

logfile:本次导入操作的日志 remap_schema:解决映射前后用户不一致的问题,前面为:源库用户,后面为:待导入库的用户

remap_tablespace: 解决表空间前后不一致的问题,前面:源表空间,后面:目标表空间

相关推荐
lbb 小魔仙1 天前
OpenClaw + cpolar 实战:远程 NAS、分享小游戏、RDP,再配置公网 AI 入口
数据库·人工智能·redis·oracle·prometheus
小刘在重生~2 天前
Oracle_day2 单行函数|组函数|分组|伪列|子查询|分页|多表连接
笔记·oracle·面试
NineData2 天前
NineData 与统信服务器操作系统完成兼容认证
数据库·oracle·操作系统·软件·数据库管理工具·ninedata·统信
山岚的运维笔记2 天前
mysql 专业笔记 -- 第 36 章:MySQL 管理
运维·数据库·笔记·后端·mysql·oracle·dba
geovindu2 天前
sql: Transaction & Concurrency Patterns using Oracel 21c
oracle·数据库开发·数据库架构
jnrjian2 天前
DRG-50857 ORA-30576 drixmd.PurgeKGL CTXSYS
数据库·oracle
jnrjian2 天前
Domain index 解决中英文 联合查询
oracle
jnrjian2 天前
Domain sync job SCHEDULER 空白job
oracle
TLA技术3 天前
LogMiner vs 裸日志解析(三):Oracle日志解析中的“前镜像”和“后镜像”,到底怎么用?
数据库·oracle·flink·dba·迁移学习
点纭3 天前
C 语言 第七章 常用函数(3)
c语言·开发语言·算法·oracle·c#