您的位置:首页 > 数据库 > Oracle

Oracle 数据迁移(从Oracle11G高版本迁移到Oracle10G低版本)

2014-11-14 23:12 351 查看
1,数据库状况
生产环境是11G,linux系统,测试环境是10G,windows系统,需要从生产环境导出一个用户下所有的数据,导入测试环境中。
因为数据量比较小,准备采用EXP和IMP工具来做。


2,在生产环境上导出用户数据
命令:
exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP

执行过程:
[oracle@localhost ~]$ exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP

Export: Release 11.2.0.1.0 - Production on Thu Nov 13 19:32:52 2014

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user PLAS
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user PLAS
............
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.'

3,在测试环境导入数据

3.1,先备份测试环境的数据
命令:
exp 'sys/tesyspd@MP_EX as sysdba' owner=PLAS buffer=10240000 FILE="F:\TEST-PLAS_EX-1114.DMP"
执行过程:
C:\Documents and Settings\Administrator>exp 'sys/tesyspd@MP_EX as sysdba' owner=PLAS buffer=10240000 FILE="F:\TEST-PLAS_EX-1114.DMP"

Export: Release 10.2.0.1.0 - Production on 星期四 11月 13 20:25:26 2014

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即将导出指定的用户...
. 正在导出 pre-schema 过程对象和操作
. 正在导出用户 PLAS 的外部函数库名
. 导出 PUBLIC 类型同义词
. 正在导出专用类型同义词
. 正在导出用户 PLAS 的对象类型定义
.........
. . 正在导出表 S_MIDORG导出了 738 行
. . 正在导出表 S_MIDUSERS导出了 2746 行
. . 正在导出表 S_ROOM_COMP导出了 3 行
. . 正在导出表 TOAD_PLAN_TABLE导出了 0 行
. . 正在导出表 T_COREMAIL导出了 82 行
. 正在导出同义词
. 正在导出视图
. 正在导出存储过程
. 正在导出运算符
. 正在导出引用完整性约束条件
. 正在导出触发器
. 正在导出索引类型
. 正在导出位图, 功能性索引和可扩展索引
. 正在导出后期表活动
. 正在导出实体化视图
. 正在导出快照日志
. 正在导出作业队列
. 正在导出刷新组和子组
. 正在导出维
. 正在导出 post-schema 过程对象和操作
. 正在导出统计信息
成功终止导出, 没有出现警告。

3.2,导入数据
C:\Documents and Settings\Administrator>IMP 'sys/tesyspd@MP_TEST as sysdba' BUFFER=10240000 FILE=F:\ORACLE_EXP\MP_EX-PLAS-20141114.DMP FROMUSER=PLAS TOUSER=PLAS
......
即将启用约束条件...
成功终止导入, 但出现警告。

C:\Documents and Settings\Administrator>

4,执行过程中错误记录

4.1,linux导出报错
[oracle@localhost ~]$ exp "system/syspl@powerdes" owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP

Export: Release 11.2.0.1.0 - Production on Thu Nov 13 19:25:47 2014

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

EXP-00056: ORACLE error 28009 encountered
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Username:
Password:

EXP-00056: ORACLE error 1017 encountered
ORA-01017: invalid username/password; logon denied
EXP-00005: all allowable logon attempts failed
EXP-00000: Export terminated unsuccessfully
[oracle@localhost ~]$

导入报错,是因为 linux /unix 转义字符,需要在上面加上转义符号,比如\',修改成如下命令即可:
exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP

4.2,Windows下导入报错


C:\Documents and Settings\Administrator> imp 'sys/tesyspd@MP_TEST as sysdba' BUFFER=10240000 FILE=D:\oracle\imp\PLAS_20141113.DMP FROMUSER=PLAS TOUSER=PLAS

Import: Release 10.2.0.1.0 - Production on 星期四 11月 13 20:53:02 2014

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options

IMP-00010: 不是有效的导出文件, 头部验证失败
IMP-00000: 未成功终止导入

解决办法: 参考文章http://www.2cto.com/database/201401/272732.html
通过工具将dmp文件头部的“11.20.00“ 改为”10.20.10“即可。

4.3,IMP表已经存在的问题
......
IMP-00015: 由于对象已存在, 下列语句失败:
"CREATE PACKAGE "sss" sss is"
""
" -- Author : ADMINISTRATOR"
" -- Created : 2012/3/20 16:14:58"
" -- Purpose : sssss"
......
IMP报已经存在的表不能CREATE的问题,通过PLSQL的界面可以在IMP之前删除用户下所以对象,比如删除表的方式为:选择Users->PLAS->Objects->Tables,选中所有表,右键点击Drop操作就会删除掉当前用户PLAS下所有表。之后再执行IMP命令。

----------------------------------------------------------------------------------------------------------------
<版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!>
原博客地址: http://blog.itpub.net/26230597/viewspace-1333180/
原作者:黄杉 (mchdba)
----------------------------------------------------------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: