oracle跨版本exdp 从高版本到低版本 从18c到10g

由于工作需要,有时候需要将oracle18c的数据同步到另一个环境的10g版本

测试环境 :

源数据库版本:18.13.0.0

目标数据库版本:10.2.0.4

结论:

1 从低版本导出,导入到高版本,可以,不需要加参数version

2 从高版本导出,导入到低版本,不可以。需要在导出的时候,加上version参数。在导入的时候加参数version无效。

源数据库:

[oracle@dp]$ expdp l5m/l5m directory=DPPATH schemas=TTT file=TTT.dmp version=10.2.0.4

Export: Release 18.0.0.0.0 - Production on Fri Jun 14 10:25:21 2024
Version 18.13.0.0.0

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

Connected to: Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Legacy Mode Active due to the following parameters:
Legacy Mode Parameter: "file=TTT.dmp" Location: Command Line, Replaced with: "dumpfile=TTT.dmp"
Legacy Mode has set reuse_dumpfiles=true parameter.

Warning: Oracle Data Pump is exporting from a database that supports long identifiers to a version that does not support long identifiers.

Starting "L5M"."SYS_EXPORT_SCHEMA_03":  l5m/******** directory=DPPATH schemas=TTT dumpfile=TTT.dmp version=10.2.0.4 reuse_dumpfiles=true 
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "TTT"."T1"                                  72.79 KB     428 rows
Master table "L5M"."SYS_EXPORT_SCHEMA_03" successfully loaded/unloaded
******************************************************************************
Dump file set for L5M.SYS_EXPORT_SCHEMA_03 is:
  /u01/dump/dp/data/TTT.dmp
Job "L5M"."SYS_EXPORT_SCHEMA_03" successfully completed at Fri Jun 14 10:27:29 2024 elapsed 0 00:02:07

导出之后将文件传到目录服务器,直接通过imdp就可以了,不需要加version参数。

[oracle@data]$ impdp l5m/l5m dumpfile=TTT.dmp directory=dumppaht

Import: Release 10.2.0.4.0 - 64bit Production on Thursday, 13 June, 2024 22:41:42

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-39087: directory name DUMPPAHT is invalid


[oracle@l5mDev121 data]$ impdp l5m/l5m dumpfile=TTT.dmp directory=dumppath

Import: Release 10.2.0.4.0 - 64bit Production on Thursday, 13 June, 2024 22:41:50

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "L5M"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "L5M"."SYS_IMPORT_FULL_01":  l5m/******** dumpfile=TTT.dmp directory=dumppath 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TTT"."T1"                                  72.79 KB     428 rows
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "L5M"."SYS_IMPORT_FULL_01" successfully completed at 22:41:53

如何从高版本数据库导出dmp至低版本数据库导入? - 墨天轮

https://www.oracle.com/a/ocom/docs/oracle-data-pump-best-practices.pdf

Export/Import DataPump Parameter VERSION - Compatibility of Data Pump Between Different Oracle Versions (Doc ID 553337.1) - 晟数学苑 - 学习塑造未来

在Shell脚本中使用Oracle Exports (expdp)工具导出数据库最近一个月的数据并保存为.dmp文件,需要分步骤进行,因为Expdp命令本身并不直接支持按时间范围筛选。以下是大概的步骤: 1. **设置环境变量**: 首先,你需要确保`expdp`命令已经安装,并配置了正确的用户名、密码以及连接到目标数据库的相关环境变量。例如: ```bash export ORACLE_HOME=/path/to/oracle_home export PATH=$PATH:$ORACLE_HOME/bin export EXPDP_HOME=$ORACLE_HOME/admin/expdp ``` 2. **创建作业**: 使用SQL*Plus或TNSnames.ora文件,创建一个Expdp作业,指定路径和文件名模板,以便将数据导出到`.dmp`文件。例如: ```sql expdp username/password directory=dir_path dumpfile=my_database_%Y%m%d.dmp logfile=my_export.log ``` `%Y%m%d`会被当前日期替换。 3. **限定时间范围**: 因为Exdp没有直接的选项来限制导出的时间范围,你需要结合其他数据库查询来获取最近一个月的数据。你可以通过查询如`DBA_DATA_FILES`视图找出一个月前的日志位置,然后调整`logfile_size_limit`参数以覆盖这段时间的数据。这一步通常需要一些SQL知识,比如找到redo log group的开始和结束位置。 4. **调度任务**: 如果你想定期运行这个脚本,你可以将其放入定时任务,如cron job,使其每天或每周自动运行一次。 5. **检查日志**: 导出过程中,记得查看`logfile`中的输出,以确认操作是否成功,是否有错误发生。 请注意,实际操作可能会因数据库版本、权限设置等差异而有所不同。此外,直接从生产环境中导出大量数据也需谨慎处理,以避免影响正常业务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值