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

oracle不同版本间数据的导入导出/oracle IMP 命令详解

2009-04-07 18:20 453 查看
Oracle的imp/exp组件是我们常用的工具,它的一个操作原则就是向下兼容。下面是据此总结的几个使用规则和相关测试:

规则1:低版本的exp/imp可以连接到高版本(或同版本)的数据库服务器,但高版本的exp/imp不能连接到低版本的数据库服务器

--1.1 使用9i客户端通过imp连接到10g数据库

C:/Documents and Settings/yuechaotian>exp userid=hdtest/test@s67 tables=(ab01) rows=n file=d:/x.dmp

Export: Release 9.2.0.1.0 - Production on 星期三 2月 20 10:09:55 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

注: 将不会导出表数据(行)

即将导出指定的表通过常规路径 ...

. . 正在导出表 AB01

在没有警告的情况下成功终止导出。

--1.2 使用10g客户端通过imp连接9i数据库:连接失败(而不是导出失败)

C:/Documents and Settings/yuechaotian>exp userid=hbjb_kf_hd/test@s46 owner=hdtest file=d:/x.dmp

Export: Release 10.2.0.1.0 - Production on 星期三 2月 20 09:57:22 2008

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

EXP-00056: 遇到 ORACLE 错误 6550

ORA-06550: 第 1 行, 第 41 列:

PLS-00302: 必须说明 'SET_NO_OUTLINES' 组件

ORA-06550: 第 1 行, 第 15 列:

PL/SQL: Statement ignored

EXP-00000: 导出终止失败

规则2:高版本exp出的dmp文件,低版本无法imp(无法识别dmp文件)

--2.1 使用10g客户端exp出10g的数据

C:/Documents and Settings/yuechaotian>exp userid=test/test@orcl owner=test file=d:/10g.dmp

Export: Release 10.2.0.1.0 - Production on 星期三 2月 20 11:16:39 2008

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

服务器使用 AL32UTF8 字符集 (可能的字符集转换)

即将导出指定的用户...

……

导出成功终止, 但出现警告。

C:/Documents and Settings/yuechaotian>

--2.2 使用9i客户端imp上面所导出的dmp文件到10g:可以连接到10g中,但无法识别文件

C:/Documents and Settings/yuechaotian>imp userid=test/test@s10g fromuser=test touser=test file=d:/10g.dmp

Import: Release 9.2.0.1.0 - Production on 星期三 2月 20 11:20:33 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

IMP-00010: 不是有效的导出文件,标题验证失败

IMP-00000: 未成功终止导入

C:/Documents and Settings/yuechaotian>

规则3:低版本exp出的dmp文件,高版本可以imp(向下兼容)

-- 3.1 使用9i客户端exp出9i中的数据

C:/Documents and Settings/yuechaotian>exp userid=test/test@s9i owner=test file=d:/9i.dmp

Export: Release 9.2.0.1.0 - Production on 星期三 2月 20 11:25:04 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

连接到: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.1.0 - Production

已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即将导出指定的用户...

……

在没有警告的情况下成功终止导出。

C:/Documents and Settings/yuechaotian>

-- 3.2 使用10g客户端imp到10g数据库中

C:/Documents and Settings/yuechaotian>imp userid=test/test@orcl fromuser=test touser=test file=d:/9i.dmp

Import: Release 10.2.0.1.0 - Production on 星期三 2月 20 11:28:46 2008

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

经由常规路径由 EXPORT:V09.02.00 创建的导出文件

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入

导入服务器使用 AL32UTF8 字符集 (可能的字符集转换)

. . 正在导入表 "AUDIT_ACTIONS"导入了 144 行

……

成功终止导入, 但出现警告。

C:/Documents and Settings/yuechaotian>

规则4:从Oracle 低版本的Export数据可以Import到Oracle高版本中,但限于Oracle的相邻版本,如从Oracle
7 到 Oracle 8。对于两个不相邻版本间进行转换,如从Oracle 6 到 Oracle 8,则应先将数据输入到中间版本—Oracle
7,再从中间数据库转入更高版本。
--我使用10g的imp功能,可以将由817导出的dmp文件直接导入10g中,这与该规则的介绍不同。(该规则出自高道强的《Oracle导入导出工具实现数据库移植》)

C:/Documents and Settings/yuechaotian>imp userid=test/test fromuser=scott touser=test file=d:/tyc.dmp

Import: Release 10.2.0.1.0 - Production on 星期三 2月 20 14:03:33 2008

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

经由常规路径由 EXPORT:V08.01.07 创建的导出文件

警告: 这些对象由 SCOTT 导出, 而不是当前用户

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入

导入服务器使用 AL32UTF8 字符集 (可能的字符集转换)

导出服务器使用 ZHS16GBK NCHAR 字符集 (可能的 ncharset 转换)

. 正在将 SCOTT 的对象导入到 TEST

. . 正在导入表 "ACCOUNT"导入了 5 行

. . 正在导入表 "BONUS"导入了 0 行

. . 正在导入表 "DEPT"导入了 4 行

. . 正在导入表 "EMP"导入了 14 行

. . 正在导入表 "RECEIPT"导入了 1 行

. . 正在导入表 "SALGRADE"导入了 5 行

即将启用约束条件...

成功终止导入, 没有出现警告。

C:/Documents and Settings/yuechaotian>

--以上操作,对于OracleXE的10g版本同样适用:

C:/Documents and Settings/yuechaotian>imp userid=test/test fromuser=scott touser=test file=d:/tyc.dmp

Import: Release 10.2.0.1.0 - Production on 星期三 2月 20 14:15:51 2008

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

连接到: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

经由常规路径由 EXPORT:V08.01.07 创建的导出文件

警告: 这些对象由 SCOTT 导出, 而不是当前用户

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入

导出服务器使用 ZHS16GBK NCHAR 字符集 (可能的 ncharset 转换)

. 正在将 SCOTT 的对象导入到 TEST

. . 正在导入表 "ACCOUNT"导入了 5 行

. . 正在导入表 "BONUS"导入了 0 行

. . 正在导入表 "DEPT"导入了 4 行

. . 正在导入表 "EMP"导入了 14 行

. . 正在导入表 "RECEIPT"导入了 1 行

. . 正在导入表 "SALGRADE"导入了 5 行

即将启用约束条件...

成功终止导入, 没有出现警告。

imp/exp 的导入导出常用:

oracle IMP 命令详解oracle IMP 命令详解

原文地址:http://www.bokee.net/bloggermodule/blog_viewblog.do?id=465310

Oracle的导入实用程序(Import utility)允许从数据库提取数据,并且将数据写入操作系统文件。imp使用的基本格式:imp[username[/password[@service]]],以下例举imp常用用法。

1. 获取帮助

imp help=y

2. 导入一个完整数据库

imp system/manager file=bible_db log=dible_db full=y ignore=y

3. 导入一个或一组指定用户所属的全部表、索引和其他对象

imp system/manager file=seapark log=seapark fromuser=seapark imp

system/manager file=seapark log=seapark fromuser=(seapark,amy,amyc,harold)

4. 将一个用户所属的数据导入另一个用户

imp system/manager file=tank log=tank fromuser=seapark touser=seapark_copy

imp system/manager file=tank log=tank fromuser=(seapark,amy)

touser=(seapark1, amy1)

5. 导入一个表

imp system/manager file=tank log=tank fromuser=seapark TABLES=(a,b)

6. 从多个文件导入

imp system/manager file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)

log=paycheck, filesize=1G full=y

7. 使用参数文件

imp system/manager parfile=bible_tables.par

bible_tables.par参数文件:

#Import the sample tables used for the Oracle8i Database Administrator's

Bible. fromuser=seapark touser=seapark_copy file=seapark log=seapark_import

8. 增量导入

imp system./manager inctype= RECTORE FULL=Y FILE=A
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: