数据的导入导出
2010-01-28 12:52
423 查看
数据的导入导出
按条件导出, 将id<3的数据导出
exp scott/tiger tables=abc file=abc_constaint.dmp query=\"where id\< 3\"
注:在oracle中, exp无法导出特定的某些字段里面的内容,必须导出所有的列数;如果需要某些特定的列,则需要用spool来完成。
exp offer1/offer@CCBU_QA_COBAR file=/home/oracle/cobar_backup/offer1.dmp
eg: exp forum/forum@oindev file=oindev_exp.dmp
条件数据的导入:
imp scott/tiger tables=abc file=abc_constaint.dmp
EXP-00056: ORACLE error 6550 encountered
ORA-06550: line 1, column 41:
PLS-00302: component 'SET_NO_OUTLINES' must be declared
ORA-06550: line 1, column 15:
PL/SQL: Statement ignored
EXP-00000: Export terminated unsuccessfully
在metalink找到原因,需要用旧版本exp来导出数据(服务器Oracle为9i2,客户端我用的是Oracle10g。换到Oracle9i2就没问题了。)
This problem occurs when using 10.2 Exp utility for 10.1,9.2,8.1.7 databases.
(2)、无法ping通tnsnames中的绑定变量
oracle@b2b_plat_13619:/home/oracle>exp offer1/offer@CCBU_QA_COBAR
Export: Release 9.2.0.4.0 - Production on Wed Jul 14 18:35:26 2010
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
EXP-00056: ORACLE error 12154 encountered
ORA-12154: TNS:could not resolve service name
EXP-00000: Export terminated unsuccessfully
且tnsping CCBU_QA_COBAR不通
原因:sqlnet.ora文件中引用了domain域(注:我们这边没使用域)
oracle@b2b_plat_13619:/home/oracle>more /home/oracle/products/9.2.0/network/admin/sqlnet.ora
# SQLNET.ORA Network Configuration File: /opt/oracle/products/9.2.0/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
MES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME)
NAMES.DEFAULT_DOMAIN = db.alibaba.com
方法:去掉域之后再tnsping,提示如下即成功!
oracle@b2b_plat_13619:/home/oracle>tnsping CCBU_QA_COBAR
TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 14-JUL-2010 18:37:58
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
/opt/oracle/products/9.2.0/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 某ip值)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ocntest)))
OK (0 msec)
此时再进行导出数据,则OK
(3)EXP-00091 Exporting questionable statistics
Cause: Export was able to export statistics, but the statistics may not be useable. The statistics are questionable because one or more of the following happened during export: a row error occurred, client character set or NCHARSET does not match with the server, a query clause was specified on export, only certain partitions or subpartitions were exported, or a fatal error occurred while processing a table.
Action: To export non-questionable statistics, change the client character set or NCHARSET to match the server, export with no query clause, or export complete tables. If desired, import parameters can be supplied so that only non-questionable statistics will be imported, and all questionable statistics will be recalculated.
解决:
linux下的oracle用户的环境变量语言集和oralce数据库中的环境变量语言集不相同。
查看oracle的环境变量语言集:
数据库服务器字符集:
select * from nls_database_parameters
客户端字符集:
select * from nls_instance_parameters
将oracle用户的环境变量语言集改成和数据库服务器字符集一样。
export NLS_LANG=american_america.ZHS16GBK
EXP-00019: failed to process parameters, type 'EXP HELP=Y' for help
EXP-00000: Export terminated unsuccessfully
这是因为在where条件中一般都会有空格, 而命令行下就会被释成几个命令行参数, 需要用单引号或双引号将整个where条件括起来, 就可以了. 在Windows下, 如何指定query参数:
exp ... query='where deptno=10'
exp ... query='where deptno=''10'''
exp ... query='where deptno"<"10'
在Solaris(C shell)下, 如何指定query参数:
exp ..... query=\"where col1 \< 1000\"
exp ..... query=\"where col1 \< '1000'\"
其他Unix平台的应当和Solaris下的一样, 我自已也经常搞错. 在上面的例子中已经说明了如何在query值中使用单引号, 因此在看完这篇后, 就应当可以写出正确的where条件了. 最好是写在一个参数文件里, 这样的话就不用注意这些了.
EXP导出10203数据的时候,出现了EXP-3错误:EXP-00003: no storage definition found for segment(41, 6024)
查询了一下METALINK,发现9205版本之前的EXP客户端,导出9205以上版本的数据时,如果表中包含LOB字段,或者表中的EXTENT超过一个,则会导致EXP-00003错误。
造成问题的原因是由于Oracle在9205及以上版本中,解决了一个查询DBA_SEGMENTS的BYTES/EXTENTS/BLOCKS列速度缓慢的错误。而解决这个bug的代价就是9204及以下版本在导出高版本数据时会碰到EXP-3这个错误。
具体的相关信息可以查询METALINK:
Bug 2948717 : Queries against DBA_SEGMENTS can be slow accessing BYTES/BLOCKS/EXTENTS columns;
Bug 3593227 "EXP-3 WHEN EXPORTING A TABLE WITH MORE THAN 1 EXTENT USING EXP BELOW 9.2.0.5"
Bug 3784697 "EXPORT OF LOB FROM 9205 WITH PRE-9205 EXP GIVES EXP-3 (NO STORAGE DEF FOUND)"
解决问题的方法到是不算复杂:
如果导出不包含LOB字段,那么可以将EXP语句中的COMPRESS参数设置为Y,重新执行导出即可。
如果包含LOB字段,或者上面的方法无效,那么需要对导出库修改exu9tne视图。在导出完成后,再将该视图恢复。
具体参考http://blog.sina.com.cn/s/blog_4b1c9e1201000a86.html
(6)版本不当导致的exp出错:
在一次exp[/u]导出操作时遇到了ORA-00904,ORA-01003错误,多方搜索也几无所得。
EXP-00008: ORACLE error 1003 encountered
服务器和客户端两边连接都很正常,百思不得解,难道是导出版本的问题?不至于啊,1024导出1023的库,之前操作过,没发现过这个问题,而且看提示不像啊,众所周知版本错误会提示ORA-06550。实在无法,最后报着死马当活马医的想法尝试换了一个同版本的客户端执行exp,结果顺利执行。
后来又经过多番尝试,发现出错的均是含lob字段的表,看来一方面oracle在执行exp时对版本的处理非常严格,即使大版本相同,小版本有略微差异也会导致exp时报错,另一方面是处理规则也存在版本延续的情况,如果不涉及到处理规则的变化,即使exp时客户端版本与服务器不符,导出时也有可能不报错(运气好的话)。
将此次事件记录下来以加强记忆,以后执行导出还是都尽可能确保版本一致吧(起码exp的客户端版本不能高于服务器)。
1、Oracle导入、导出
(1)导出数据:
exp scott/tiger tables=abc file=abc_bk.dmp按条件导出, 将id<3的数据导出
exp scott/tiger tables=abc file=abc_constaint.dmp query=\"where id\< 3\"
注:在oracle中, exp无法导出特定的某些字段里面的内容,必须导出所有的列数;如果需要某些特定的列,则需要用spool来完成。
(2)远程导出数据
远程导出某用户下面的所有数据:exp offer1/offer@CCBU_QA_COBAR file=/home/oracle/cobar_backup/offer1.dmp
eg: exp forum/forum@oindev file=oindev_exp.dmp
(3)导入数据:
imp scott/tiger buffer=64000 file=abc_bk.dmp full=y条件数据的导入:
imp scott/tiger tables=abc file=abc_constaint.dmp
2、导出时遇到的问题分析
(1)、用EXP命令导出数据时,出现:EXP-00056: ORACLE error 6550 encountered
ORA-06550: line 1, column 41:
PLS-00302: component 'SET_NO_OUTLINES' must be declared
ORA-06550: line 1, column 15:
PL/SQL: Statement ignored
EXP-00000: Export terminated unsuccessfully
在metalink找到原因,需要用旧版本exp来导出数据(服务器Oracle为9i2,客户端我用的是Oracle10g。换到Oracle9i2就没问题了。)
Cause
Use of Higher Version Export utility (10.2.0.1) on Lower version database(9.2.0.6).This problem occurs when using 10.2 Exp utility for 10.1,9.2,8.1.7 databases.
Solution
As per compatibility Matrix,You need to use the export utility of the lower version of source and target database.(2)、无法ping通tnsnames中的绑定变量
oracle@b2b_plat_13619:/home/oracle>exp offer1/offer@CCBU_QA_COBAR
Export: Release 9.2.0.4.0 - Production on Wed Jul 14 18:35:26 2010
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
EXP-00056: ORACLE error 12154 encountered
ORA-12154: TNS:could not resolve service name
EXP-00000: Export terminated unsuccessfully
且tnsping CCBU_QA_COBAR不通
原因:sqlnet.ora文件中引用了domain域(注:我们这边没使用域)
oracle@b2b_plat_13619:/home/oracle>more /home/oracle/products/9.2.0/network/admin/sqlnet.ora
# SQLNET.ORA Network Configuration File: /opt/oracle/products/9.2.0/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
MES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME)
NAMES.DEFAULT_DOMAIN = db.alibaba.com
方法:去掉域之后再tnsping,提示如下即成功!
oracle@b2b_plat_13619:/home/oracle>tnsping CCBU_QA_COBAR
TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 14-JUL-2010 18:37:58
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
/opt/oracle/products/9.2.0/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 某ip值)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ocntest)))
OK (0 msec)
此时再进行导出数据,则OK
(3)EXP-00091 Exporting questionable statistics
Cause: Export was able to export statistics, but the statistics may not be useable. The statistics are questionable because one or more of the following happened during export: a row error occurred, client character set or NCHARSET does not match with the server, a query clause was specified on export, only certain partitions or subpartitions were exported, or a fatal error occurred while processing a table.
Action: To export non-questionable statistics, change the client character set or NCHARSET to match the server, export with no query clause, or export complete tables. If desired, import parameters can be supplied so that only non-questionable statistics will be imported, and all questionable statistics will be recalculated.
解决:
linux下的oracle用户的环境变量语言集和oralce数据库中的环境变量语言集不相同。
查看oracle的环境变量语言集:
数据库服务器字符集:
select * from nls_database_parameters
客户端字符集:
select * from nls_instance_parameters
将oracle用户的环境变量语言集改成和数据库服务器字符集一样。
export NLS_LANG=american_america.ZHS16GBK
(4)Oracle的exp工具有一个query参数可以指定一个where条件来有条件地导出记录, 对于不经常用这个选项的人来说, 经常会遇到这样的错误:
LRM-00112: multiple values not allowed for parameter 'query'EXP-00019: failed to process parameters, type 'EXP HELP=Y' for help
EXP-00000: Export terminated unsuccessfully
这是因为在where条件中一般都会有空格, 而命令行下就会被释成几个命令行参数, 需要用单引号或双引号将整个where条件括起来, 就可以了. 在Windows下, 如何指定query参数:
exp ... query='where deptno=10'
exp ... query='where deptno=''10'''
exp ... query='where deptno"<"10'
在Solaris(C shell)下, 如何指定query参数:
exp ..... query=\"where col1 \< 1000\"
exp ..... query=\"where col1 \< '1000'\"
其他Unix平台的应当和Solaris下的一样, 我自已也经常搞错. 在上面的例子中已经说明了如何在query值中使用单引号, 因此在看完这篇后, 就应当可以写出正确的where条件了. 最好是写在一个参数文件里, 这样的话就不用注意这些了.
(5) EXP数据时出现exp-00003错误
原因:用低版本导高版本数据库数据造成的EXP导出10203数据的时候,出现了EXP-3错误:EXP-00003: no storage definition found for segment(41, 6024)
查询了一下METALINK,发现9205版本之前的EXP客户端,导出9205以上版本的数据时,如果表中包含LOB字段,或者表中的EXTENT超过一个,则会导致EXP-00003错误。
造成问题的原因是由于Oracle在9205及以上版本中,解决了一个查询DBA_SEGMENTS的BYTES/EXTENTS/BLOCKS列速度缓慢的错误。而解决这个bug的代价就是9204及以下版本在导出高版本数据时会碰到EXP-3这个错误。
具体的相关信息可以查询METALINK:
Bug 2948717 : Queries against DBA_SEGMENTS can be slow accessing BYTES/BLOCKS/EXTENTS columns;
Bug 3593227 "EXP-3 WHEN EXPORTING A TABLE WITH MORE THAN 1 EXTENT USING EXP BELOW 9.2.0.5"
Bug 3784697 "EXPORT OF LOB FROM 9205 WITH PRE-9205 EXP GIVES EXP-3 (NO STORAGE DEF FOUND)"
解决问题的方法到是不算复杂:
如果导出不包含LOB字段,那么可以将EXP语句中的COMPRESS参数设置为Y,重新执行导出即可。
如果包含LOB字段,或者上面的方法无效,那么需要对导出库修改exu9tne视图。在导出完成后,再将该视图恢复。
具体参考http://blog.sina.com.cn/s/blog_4b1c9e1201000a86.html
(6)版本不当导致的exp出错:
在一次exp[/u]导出操作时遇到了ORA-00904,ORA-01003错误,多方搜索也几无所得。
EXP-00008: ORACLE error 1003 encountered
服务器和客户端两边连接都很正常,百思不得解,难道是导出版本的问题?不至于啊,1024导出1023的库,之前操作过,没发现过这个问题,而且看提示不像啊,众所周知版本错误会提示ORA-06550。实在无法,最后报着死马当活马医的想法尝试换了一个同版本的客户端执行exp,结果顺利执行。
后来又经过多番尝试,发现出错的均是含lob字段的表,看来一方面oracle在执行exp时对版本的处理非常严格,即使大版本相同,小版本有略微差异也会导致exp时报错,另一方面是处理规则也存在版本延续的情况,如果不涉及到处理规则的变化,即使exp时客户端版本与服务器不符,导出时也有可能不报错(运气好的话)。
将此次事件记录下来以加强记忆,以后执行导出还是都尽可能确保版本一致吧(起码exp的客户端版本不能高于服务器)。
相关文章推荐
- sqlserver bcp(数据导入导出工具)一般用法与命令详解
- PLSQL导入/导出数据方法
- OpenRefine导入CSV文件,数据清理后导出JSON格式
- 分享一次Oracle数据导入导出经历
- Sqlite 命令行导出、导入数据
- 将数据导入hive,将数据从hive导出
- SQL SERVER 和EXCEL的数据导入导出
- mysql导入数据 导出数据系列语句
- SQLServer 工具箱v1.1(SQL脚本排序,日志清除,数据导入导出)附源代码
- Oracle--数据的导入与导出(exp/imp命令详解2)
- MySQL数据库结构和数据的导出和导入
- 基于Metronic的Bootstrap开发框架经验总结(7)--数据的导入、导出及附件的查看处理
- 在VBA中实现两个ACCESS数据库之间的数据导出与导入
- Oracle数据导入导出imp/eXP
- oracle 备份还原数据库,及数据导入导出的文章地址,个人经验总结
- Sqoop的安装与数据的导入导出
- [转载]Oracle数据导入导出imp/exp
- 大批量导入导出数据的一点体会。
- Oracle数据导入导出imp/exp命令
- MySQL数据的导出和导入工具