3

我正在使用以下命令将我的序列导出到 Oracle 中的转储文件:

expdp user/pwd DIRECTORY=user_exp DUMPFILE=morder.dmp  include=sequence:HR.EMPLOYEES 

其中 EMPLOYEES 是我的序列名称。但是,我收到此错误:

ORA-39001 invalid argument value
ORA-39071 Value for INCLUDE is badly formed
ORA-00920 invalid relational operator

有人可以指导一下吗?我究竟做错了什么?

4

3 回答 3

2

对象名称子句必须用双引号括起来,并且必须有一个关系运算符

name_clause 是可选的。它允许在对象类型中细粒度地选择特定对象。它是一个 SQL 表达式,用作类型对象名称的过滤器。它由一个 SQL 运算符和与指定类型的对象名称进行比较的值组成。name_clause 仅适用于其实例具有名称的对象类型(例如,它适用于 TABLE,但不适用于 GRANT)。它必须用冒号与对象类型分隔并用双引号括起来,因为需要用单引号来分隔名称字符串。

但它也不能包含模式名称;它必须是一个对象名称。如果您以expdpHR 用户身份连接,那么无论如何这都是默认设置,您可以执行以下操作:

expdp hr/pwd DIRECTORY=user_exp DUMPFILE=morder.dmp include=sequence:"= 'EMPLOYEES'"

如果您以不同的特权用户身份连接,则需要包含该schemas子句,否则它将无法找到对象:

expdp system/pwd DIRECTORY=user_exp DUMPFILE=morder.dmp schemas=hr include=sequence:"= 'EMPLOYEES'"

根据您的操作系统,您可能需要逃避各种事情:

根据您的操作系统,在为此参数指定值时使用引号可能还需要您使用转义字符。Oracle 建议您将此参数放在参数文件中,这样可以减少命令行中可能需要的转义字符的数量。请参阅“在数据泵命令行上使用引号”

在 Linux/bash 上,include 子句最终为:

... include=sequence:\"= \'EMPLOYEES\'\" 

双引号和单引号都被转义了。从上一个问题您可能在 Windows 上,我只需要转义双引号:

... include=sequence:\"= 'EMPLOYEES'\" 

最后,EMPLOYEES看起来像一个表名;你可能真的想要EMPLOYEES_SEQ

... include=sequence:\"= 'EMPLOYEES_SEQ'\" 
于 2015-11-16T19:27:41.300 回答
0

这是我的环境中的复制/粘贴:

[oracle@testsrv ~]$ expdp uuu/uuu schemas=uuu DIRECTORY=dir1 DUMPFILE=morder3.dmp  include=sequence

Export: Release 12.1.0.2.0 - Production on Mon Nov 16 22:16:59 2015

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "UUU"."SYS_EXPORT_SCHEMA_01":  uuu/******** schemas=uuu DIRECTORY=dir1 DUMPFILE=morder3.dmp include=sequence 
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Master table "UUU"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for UUU.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/morder3.dmp
Job "UUU"."SYS_EXPORT_SCHEMA_01" successfully completed at Mon Nov 16 22:17:03 2015 elapsed 0 00:00:03

[oracle@testsrv ~]$ 
于 2015-11-16T20:18:33.653 回答
0

如果您想从特定 SCHEMA 导出序列,请使用:

expdp user/pwd SCHEMAS=HR DIRECTORY=user_exp DUMPFILE=morder.dmp include=sequence:EMPLOYEES

(添加 SCHEMAS 并删除序列的所有者)

于 2015-11-16T19:08:41.853 回答