[英]How to exclude certain tables from Oracle datapump export
I have a large number of user schemas in my Oracle database. 我的Oracle数据库中有大量的用户架构。 I wish to export the table data for these schemas but exclude any tables that are named with the second character an underscore. 我希望导出这些模式的表数据,但要排除以下划线第二个字符命名的任何表。
For example I wish to export tables TPI_SUMMARY
, DFXRRT
and RTAFF
but exclude C_NAMES
, G_BEARS
etc. Basically just want to exclude anything with an underscore as the second character 例如,我希望导出表TPI_SUMMARY
, DFXRRT
和RTAFF
但排除C_NAMES
, G_BEARS
等。基本上只想排除带有下划线作为第二个字符的任何内容
I am using Oracle data pump: 我正在使用Oracle数据泵:
expdp system/xxxxx@string parfile=parfile.par
The parfile
contains : 该parfile
包含:
INCLUDE=TABLE:"IN(select table_name from dba_tables where table_name not like '_\_%')"
EXCLUDE=SCHEMA:"='SYS','SYSTEM','SYSMAN','DBSNMP','OUTLN','APPQOSSYS'"
DIRECTORY=paul_test
DUMPFILE=infrep_temp1.dmp
FULL=Y
LOGFILE=Daily_Backup_infrep_temp1.log
I just cannot get this to work. 我只是无法使它正常工作。 I think that the EXCLUDE
bit is OK but the INCLUDE
query is wrong. 我认为 EXCLUDE
位还可以,但是INCLUDE
查询是错误的。 The DIRECTORY
, DUMPFILE
and LOGFILE
are all OK. DIRECTORY
, DUMPFILE
和LOGFILE
都可以。
I get the following: 我得到以下内容:
Export: Release 11.2.0.4.0 - Production on Thu May 4 16:41:48 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
ORA-39001: invalid argument value
ORA-39071: Value for EXCLUDE is badly formed.
ORA-00933: SQL command not properly ended
Any ideas? 有任何想法吗? I'm really struggling to get this to work. 我真的很想让这个工作。
The error refers to EXCLUDE
, not INCLUDE
: 错误是指EXCLUDE
而不是INCLUDE
:
ORA-39071: Value for EXCLUDE is badly formed
... and it is indeed that which is wrong. ...的确是错的。 You're trying to use equality with multiple values; 您正在尝试将相等性与多个值一起使用; you just need to use an IN()
again: 您只需要再次使用IN()
:
EXCLUDE=SCHEMA:"IN('SYS','SYSTEM','SYSMAN','DBSNMP','OUTLN','APPQOSSYS')"
But as it says in the documentation : 但是正如文档中所说 :
The
EXCLUDE
andINCLUDE
parameters are mutually exclusive.EXCLUDE
和INCLUDE
参数是互斥的。
You are allowed to use two EXCLUDE
clauses though, so you can negate the first INCLUDE
: 但是您可以使用两个EXCLUDE
子句,因此可以否定第一个INCLUDE
:
EXCLUDE=TABLE:"NOT IN(select table_name from dba_tables where table_name not like '_\_%')"
EXCLUDE=SCHEMA:"IN('SYS','SYSTEM','SYSMAN','DBSNMP','OUTLN','APPQOSSYS')"
or as that's now a double-negative: 或因为这现在是双重负数:
EXCLUDE=TABLE:"IN(select table_name from dba_tables where table_name like '_\_%')"
EXCLUDE=SCHEMA:"IN('SYS','SYSTEM','SYSMAN','DBSNMP','OUTLN','APPQOSSYS')"
But that like
doesn't match as you expect; 但是, like
你期望不符; you need to add an escape
clause, and in this context you need to escape the backslash by doubling it up: 您需要添加一个escape
子句,在这种情况下,您需要通过将其加倍来转义反斜杠:
EXCLUDE=TABLE:"IN(select table_name from dba_tables where table_name like '_\_%' escape '\\')"
or you could use substr()
instead: 或者您可以使用substr()
代替:
EXCLUDE=TABLE:"IN(select table_name from dba_tables where substr(table_name, 2, 1) = '_')"
You could also, if you have a list of schemas you do want, use two INCLUDE
clauses instead - which might be simpler that listing all of the built-in schemas, which can vary. 如果您有想要的模式列表,也可以改用两个INCLUDE
子句-列出所有内置模式可能会更简单,后者可能有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.