如何使用命令行仅从oracle数据库中导出选定的函数、选定的过程、选定的视图和选定的表?

How to export selected functions, selected procedures, selected views and selected tables only from oracle database using command line?

假设我要导出

所以我在 CMD 上触发命令如下,

(1) expdp system/manager@DB3 directory=backupdir dumpfile=backup.dmp logfile=backup.log include=view:"IN ('V1','V2')", function:"IN ('f1','f2')" , 程序:"IN ('p1','p2')", table:"IN ('T1','T2')"

(2) expdp system/manager@DB3 directory=backupdir dumpfile=backup.dmp logfile=backup.log include=view:"IN ('V1','V2')" include=function:"IN ('f1','f2')" include=程序:"IN ('p1','p2')" include=table:"IN ('T1','T2')"

这两个命令都不起作用:

Error : ORA-39071: Value for INCLUDE is badly formed.


以下命令有效,但它仅导出指定的表。它不导出视图、过程和函数。

(3) expdp system/manager@DB3 directory=backupdir dumpfile=backup.dmp logfile=backup.log include=view,procedure,function,table:"IN ('T1','T2')"

怎么办?

ORA-39071: Value for INCLUDE is badly formed

命令行不喜欢引号。有两种方法可以解决这个问题。

首先是转义引号:

expdp system/manager@DB3 directory=backupdir dumpfile=backup.dmp logfile=backup.log 
include=view:\"IN (\'V1\',\'V2\')\" include=function:\"IN (\'f1\',\'f2\')\" include=procedure:\"IN (\'p1\',\'p2\')\" include=table:\"IN (\'T1\',\'T2\')\"

如果这看起来很乏味(确实如此),第二个选项是定义一个参数文件。您可以在其中包含所有选项,而无需转义引号,只需 运行 expdp 和 PARFILE 参数。


There are no any changes in Schema 'DBpractice' in which I want to import the tables, views, functions and procedures that have been exported from schema named DB3.

这确实是一个新问题,但解决方案非常简单:您需要 运行 impdp 和带有 source_schema:target_schema 的 REMAP_SCHEMA 参数。所以在你的情况下是

impdp system/manager directory=backupdir dumpfile=backup.dmp remap_schema=db3:DBpractice