简体   繁体   English

使用“expdp”在Oracle中导出序列

[英]Export sequence in Oracle using “expdp”

I am using the following command to export my sequence to a dump file in Oracle: 我使用以下命令将我的序列导出到Oracle中的转储文件:

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

where EMPLOYEES is my sequence name. 其中EMPLOYEES是我的序列名称。 However, I get this error: 但是,我收到此错误:

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

Can someone please guide about this? 有人可以指导一下吗? What am I doing wrong? 我究竟做错了什么?

The object name clause has to be enclosed in double-quotes, and has to have a relational operator : 对象名称子句必须用双引号括起来,并且必须有一个关系运算符

The name_clause is optional. name_clause是可选的。 It allows fine-grained selection of specific objects within an object type. 它允许在对象类型中细粒度选择特定对象。 It is a SQL expression used as a filter on the object names of the type. 它是一个SQL表达式,用作对类型的对象名称的过滤器。 It consists of a SQL operator and the values against which the object names of the specified type are to be compared. 它由SQL运算符和要与之比较指定类型的对象名称的值组成。 The name_clause applies only to object types whose instances have names (for example, it is applicable to TABLE, but not to GRANT). name_clause仅适用于其实例具有名称的对象类型(例如,它适用于TABLE,但不适用于GRANT)。 It must be separated from the object type with a colon and enclosed in double quotation marks, because single quotation marks are required to delimit the name strings. 必须使用冒号将其与对象类型分开并用双引号括起来,因为需要使用单引号来分隔名称字符串。

But it also can't include a schema name; 但它也不能包含模式名称; it just has to be an object name. 它只需要是一个对象名称。 If you are connecting to expdp as the HR user then that's the default anyway and you can do: 如果您作为HR用户连接到expdp ,那么无论如何这都是默认值,您可以执行以下操作:

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

If you're connecting as a different, privileged, user you need to include the schemas clause, or it won't be able to find the object: 如果您要作为另一个特权用户进行连接,则需要包含schemas子句,否则它将无法找到该对象:

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

Depending on your operating system you may need to escape various things: 根据您的操作系统,您可能需要逃避各种事情:

Depending on your operating system, the use of quotation marks when you specify a value for this parameter may also require that you use escape characters. 根据您的操作系统,为此参数指定值时使用引号可能还需要使用转义字符。 Oracle recommends that you place this parameter in a parameter file, which can reduce the number of escape characters that might otherwise be needed on the command line. Oracle建议您将此参数放在参数文件中,这样可以减少命令行上可能需要的转义字符数。 See "Use of Quotation Marks On the Data Pump Command Line" . 请参阅“在数据泵命令行上使用引号”

On Linux/bash the include clause ends up as: 在Linux / bash上,include子句最终为:

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

with both the double-quotes and single-quotes escaped. 双引号和单引号都被转义。 From a previous question you may be on Windows, where I only the double-quotes need to be escaped: 从上一个问题开始,您可能在Windows上,我只需要转义双引号:

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

Finally, EMPLOYEES looks like a table name; 最后, EMPLOYEES看起来像一个表名; you probably really want EMPLOYEES_SEQ : 你可能真的想要EMPLOYEES_SEQ

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

In case you want to export sequence from specific SCHEMA use this: 如果您想从特定SCHEMA导出序列,请使用以下命令:

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

(add SCHEMAS and remove the owner od the sequence) (添加SCHEMAS并删除序列的所有者)

Here is the copy/paste from my environment: 这是我环境中的复制/粘贴:

[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 ~]$ 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM