今天要求将部分表数据导出html
提供的exp导出脚本以下:bash
USERID=x/x@x BUFFER=102400 ROWS=Y LOG=T_DAYLOG_CALLBYSERVICE.log FILE=T_DAYLOG_CALLBYSERVICE.dmp tables=T_DAYLOG_CALLBYSERVICE query="where logdate between to_date('20150810','YYYYMMDD') and to_date('20150828','YYYYMMDD')"
尝试执行报错oracle
$exp parfile=T_DAYLOG_CALLBYSERVICE.PAR Export: Release 10.2.0.4.0 - Production on Tue Sep 1 16:05:15 2015 Copyright (c) 1982, 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 Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... . . exporting table T_DAYLOG_CALLBYSERVICE 10197 rows exported EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. Export terminated successfully with warnings.
如其提示以报错EXP-00091,查看错误app
[oracle@SH-SRV-UIDB:/u01/script]$oerr exp 00091
00091, 00000, "Exporting questionable statistics."
// *Cause: Export was able export statistics, but the statistics may not be
// usuable. 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,
// 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.ide
根据上述的要求多是字符集不符合,或者导出时指定查询子,分区或子分区被导出,或处理表的时候发生的错误等(翻译能力有限,仅能这样理解)。工具
查看客户端和服务端字符集是否相符优化
SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- AMERICAN_AMERICA.ZHS16GBK select * from nls_database_parameters t where t.parameter='NLS_CHARACTERSET'; select * from v$nls_parameters where parameter='NLS_CHARACTERSET'
在环境变量中增长语言设定翻译
export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK' echo $NLS_LANG
从新导出依旧报00091的错,尝试去掉query也报错,修改脚本尝试使用expdp工具导出表。日志
USERID=x/x@x DIRECTORY=BACKUPDIR COMPRESSION=NONE CONTENT=ALL LOGFILE=T_DAYLOG_CALLBYSERVICE.log DUMPFILE=T_DAYLOG_CALLBYSERVICE.dmp TABLES=T_DAYLOG_CALLBYSERVICE QUERY="where logdate between to_date('20150810','YYYYMMDD') and to_date('20150828','YYYYMMDD')"
查看日志正确导出,但仔细观察发现导出的行数与exp导出相同均为10197行。server
Export: Release 10.2.0.4.0 - 64bit Production on Tuesday, 01 September, 2015 15:24:24 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 Starting "ICD"."SYS_EXPORT_TABLE_01": parfile=T_DAYLOG_CALLBYSERVICE.PAR Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 168 MB Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS. . exported "ICD"."T_DAYLOG_CALLBYSERVICE" 980.4 KB 10197 rows Master table "ICD"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for ICD.SYS_EXPORT_TABLE_01 is: /u01/temp/T_DAYLOG_CALLBYSERVICE.dmp Job "ICD"."SYS_EXPORT_TABLE_01" successfully completed at 15:24:28
也就是说,导出应该是成功的,但由于某些缘由仍是报错。
在文档EXP Utility Reports EXP-91 During Export (文档 ID 730106.1)中,笔者找到了这个问题的解释。
Oracle统计量是CBO的工做基础。Oracle优化器在发展历程中,经历了从RBO到CBO的演变过程。RBO时代,优化器生成规则是以代码的方式固化在Oracle代码中的。而CBO的工做是基于数据对象统计量。统计量反映在实体上,就是一系列的元数据信息。在9i时代,CBO与RBO共同做用,并且统计量是须要人工进行收集维护的。并且,因为数据变化的缘由,在一些早期CBO版本中,“实时”统计量每每还不能得到最好的执行计划。因此,在9i的Exp/Imp工具开始,统计量导出就成为Exp工具默认行为。
也就是说exp工具在导出时使用了统计功能,而报错的发生就和统计有关。问题没有能解决