关于expdp中query用法小结-创新互联-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
关于expdp中query用法小结-创新互联

  今天看到群里有人问到关于在使用expdp导出数据中使用query参数报错的解决方法,自己也出于好奇心瞎折腾了一把,现记录如下

创新互联基于分布式IDC数据中心构建的平台为众多户提供成都服务器托管 四川大带宽租用 成都机柜租用 成都服务器租用。

1.第一次尝试的时候

[oracle@DB ~]$ expdp scott/scott tables=emp1 dumpfile=emp1.dmp logfile=emp1.log query=emp1:"where rownum < 5"   Export: Release 11.2.0.4.0 - Production on 星期日 6月 18 01:06:05 2017   Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options ORA-39001: 参数值无效 ORA-39035: 已经指定了数据过滤器 SUBQUERY。

关于expdp 中query用法小结

ORA-39001: 参数值无效 ORA-39035: 已经指定了数据过滤器 SUBQUERY。

上述错误说明query语法写的有问题

正确写法要用\转义引号

于是再次编写了一下,执行,OK!

[oracle@DB ~]$ expdp scott/scott tables=emp1 dumpfile=emp1.dmp logfile=emp1.log query=\"where rownum \< 5\"   Export: Release 11.2.0.4.0 - Production on 星期日 6月 18 01:18:52 2017   Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 启动 "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** tables=emp1 dumpfile=emp1.dmp logfile=emp1.log query="where rownum < 5"  正在使用 BLOCKS 方法进行估计... 处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA 使用 BLOCKS 方法的总估计: 64 KB 处理对象类型 TABLE_EXPORT/TABLE/TABLE . . 导出了 "SCOTT"."EMP1"                              8.179 KB       4 行 已成功加载/卸载了主表 "SCOTT"."SYS_EXPORT_TABLE_01"  ****************************************************************************** SCOTT.SYS_EXPORT_TABLE_01 的转储文件集为:   /u01/app/oracle/admin/orcl/dpdump/emp1.dmp 作业 "SCOTT"."SYS_EXPORT_TABLE_01" 已于 星期日 6月 18 01:19:03 2017 elapsed 0 00:00:10 成功完成

关于expdp 中query用法小结

通过上面截图可以看到:1中双引号和小于号前面都要加上反斜线\转义,在实际oracle中会把这些反斜线去掉来执行,注意观察2处。

当然结果是OK的,把原表备份一下然后删除,导入验证一下,如下:

关于expdp 中query用法小结

2.答主突发奇想又测试了一种情况,就是当query条件中有大于号的情况。如下:

[oracle@DB ~]$ expdp scott/scott tables=emp1 dumpfile=emp1_2.dmp logfile=emp1.log query=\"where hiredate > to_date\(\'1982/01/02\',\'yyyy/mm/dd\'\)\" -bash: to_date('1982/01/02','yyyy/mm/dd')": No such file or directory

关于expdp 中query用法小结

看到结果没,如果条件中有大于号而又没有加反斜线,系统把这种大于号默认是重定义符号。如下所示这种:

关于expdp 中query用法小结

更改一下,再次执行,就OK了。童鞋们请重点观察下图中标注的1、2处。

[oracle@DB ~]$ expdp scott/scott tables=emp1 dumpfile=emp1_2.dmp logfile=emp1.log query=\"where hiredate \> to_date\(\'1982/01/02\',\'yyyy/mm/dd\'\)\"   Export: Release 11.2.0.4.0 - Production on 星期日 6月 18 01:59:56 2017   Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 启动 "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** tables=emp1 dumpfile=emp1_2.dmp logfile=emp1.log query="where hiredate > to_date('1982/01/02','yyyy/mm/dd')"  正在使用 BLOCKS 方法进行估计... 处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA 使用 BLOCKS 方法的总估计: 64 KB 处理对象类型 TABLE_EXPORT/TABLE/TABLE . . 导出了 "SCOTT"."EMP1"                              8.125 KB       3 行 已成功加载/卸载了主表 "SCOTT"."SYS_EXPORT_TABLE_01"  ****************************************************************************** SCOTT.SYS_EXPORT_TABLE_01 的转储文件集为:   /u01/app/oracle/admin/orcl/dpdump/emp1_2.dmp 作业 "SCOTT"."SYS_EXPORT_TABLE_01" 已于 星期日 6月 18 02:00:01 2017 elapsed 0 00:00:04 成功完成

关于expdp 中query用法小结

3.如果有童鞋想一下子导出多张表时,需如下定义:

expdp scott/scott tables=emp1,emp2 dumpfile=emp.dmp logfile=emp1.log query=emp1:\"where rownum<5\",emp2:\"where rownum<5\"

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:关于expdp中query用法小结-创新互联
链接分享:http://scgulin.cn/article/geojc.html