按条件导出数据

本文介绍了解决在MS-Windows平台上使用Oracle Export工具时出现的EXP-00056及ORA-00911错误的方法。主要原因是查询参数中的语法错误导致,特别是涉及特殊字符时。文章提供了正确的语法示例来帮助用户避免此类错误。
Subject: EXP-56 and ORA-911 During Export Using The Query Clause
Doc ID: Note:205074.1 Type: PROBLEM
Last Revision Date: 25-OCT-2005 Status: PUBLISHED


Facts
~~~~~
1. Oracle Releases 8.1.7 or upwards on MS-Windows Platform.

2. Perform a Table export using the QUERY clause
e.g.:
C:\> exp scott/tiger tables=scott.emp
query=\"WHERE job=\'SALESMAN\' AND sal\<1600\"
file=PartEmp.dump log=PartEmpExp.log


Symptoms
~~~~~~~~
Your Export using the QUERY clause terminates successfully with
the following error messages:

... (left out first part)

About to export specified tables via Conventional Path ...
. . exporting table EMP
EXP-00056: ORACLE error 911 encountered
ORA-00911: invalid character
Export terminated successfully with warnings.

If you import the dump file in another existing user schema, e.g.:
C:\> imp system/manager fromuser=scott touser=steve
file=PartEmp.dump log=PartEmpImp.log
only the table without rows will be imported.


Changes
~~~~~~~
1. You recently added or modified the QUERY clause of your export statement.

2. You recently ported a Unix script on your MS-Windows platform.


Cause
~~~~~
You are most probably encountering these
EXP-00056: ORACLE error 911 encountered
ORA-00911: invalid character
error messages due to some syntax errors in your where condition specified
by the QUERY parameter.

The escape character ('\') has to be used in a different way depending your
platform.


Fix
~~~
Double-check the value assigned to your QUERY parameter.

On MS-Windows platforms, don't use the escape character (\) neither before
single quotes ('), double-quotes (" nor before any arithmetical signs (<, >
within the where condition.

You only need to enclose your QUERY parameter with either \" or with
triple quotes """.

For example:
To export a subset of scott's emp table equivalent to

SQL> SELECT * FROM emp WHERE job='SALESMAN' AND sal<1600;

On MS-Windows platforms, you'll need to use one of the following syntax:
Either:
C:\> exp scott/tiger tables=scott.emp
query=\"WHERE job='SALESMAN' AND sal<1600\"
file=PartEmp.dump log=PartEmpExp.log
or
C:\> exp scott/tiger tables=scott.emp
query="""WHERE job='SALESMAN' AND sal<1600"""
file=PartEmp.dump log=PartEmpExp.log

Instead of the following one used on most common Unix platforms:
$ exp scott/tiger tables=scott.emp
query=\"WHERE job=\'SALESMAN\' AND sal\<1600\"
file=PartEmp.dump log=PartEmpExp.log

Note that double quotes (", single quotes ('), greater than (> and lower
than (< are UNIX reserved characters and thus need to be escaped on UNIX
platforms.


Related Documents
~~~~~~~~~~~~~~~~~
- Note 91864.1 Query= Syntax in Export in 8i
- Oracle9i Database Utilities Release 2 (9.2), Chapter 1 - Export
available online :
http://docs.oracle.com/cd_a97630 ... 52/ch01.htm#1005843
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值