如何使用 Oracle 数据泵导出实用程序在本地计算机中创建转储文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8394243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:45:09  来源:igfitidea点击:

How to use Oracle data pump export utility to create dump file in local machine?

oracleexport

提问by nayakam

Oracle data pump export utility expect a parameter DIRECTORY (DBA_DIRECTORIES) which exist in DB server. Is it possible to map this directory to local machine or is there any other way to export multiple table to local from oracle database?

Oracle 数据泵导出实用程序需要 DB 服务器中存在的参数 DIRECTORY (DBA_DIRECTORIES)。是否可以将此目录映射到本地计算机,或者是否有任何其他方法可以将多个表从 oracle 数据库导出到本地?

回答by prof

If using Data Pump, there is no direct way to store a dump file on your local machine. That is the way how Data Pump designed.

如果使用数据泵,则无法直接在本地计算机上存储转储文件。这就是数据泵的设计方式。

However, there is one of possible ways to achieve what you want. A workaround has two steps:

但是,有一种可能的方法可以实现您想要的。解决方法有两个步骤:

  1. Run expdpas usual, which creates a dump file on server
  2. Use ocptool to transfer a dump file from a database server to your local machine (and back, if you want to).
  1. expdp照常运行,在服务器上创建一个转储文件
  2. 使用ocp工具将转储文件从数据库服务器传输到您的本地计算机(如果需要,也可以返回)。

An ocptool stands for "Oracle Copy" and written exactly for the purpose of copying dump files back and forth from/to a database server. It is available here: https://github.com/maxsatula/ocp/releases/download/v0.1/ocp-0.1.tar.gzThat is a source distribution, so once downloaded and unpacked, run ./configure && make

一种ocp工具代表“Oracle Copy”,其编写完全是为了从/向数据库服务器来回复制转储文件。它可以在这里找到:https: //github.com/maxsatula/ocp/releases/download/v0.1/ocp-0.1.tar.gz这是一个源代码分发,所以一旦下载并解压,运行./configure && make

(Hopefully you do not have Windows on a client side, because I never tried to compile it there)

(希望您在客户端没有 Windows,因为我从未尝试在那里编译它)

That is a simple command-line tool with a simple syntax. For example, this command will pull a file for you:

这是一个具有简单语法的简单命令行工具。例如,此命令将为您拉取一个文件:

ocp <connection_string> DATA_PUMP_DIR:remote_file_name.dmp local_file_name.dmp

ocp <connection_string> DATA_PUMP_DIR:remote_file_name.dmp local_file_name.dmp

The tool uses a database connection and a minimum set of database privileges.

该工具使用数据库连接和最少的数据库权限集。

Update:

更新:

Finally I was able to adjust the source code and build ocptool for Windows 32-bit:

最后,我能够ocp为 Windows 32 位调整源代码和构建工具:

https://github.com/maxsatula/ocp/releases/download/v0.1/ocp-0.1-win32.zip

https://github.com/maxsatula/ocp/releases/download/v0.1/ocp-0.1-win32.zip

Compiled/tested with 32-bit Instant Client 11.2.0.4 available here: http://www.oracle.com/technetwork/topics/winsoft-085727.html

使用 32 位 Instant Client 11.2.0.4 编译/测试,可在此处获得:http: //www.oracle.com/technetwork/topics/winsoft-085727.html

instantclient-basiclite-nt-11.2.0.4.0.zip (20,258,449 bytes)

Instantclient-basiclite-nt-11.2.0.4.0.zip(20,258,449 字节)

I believe it will work with a full Oracle Client installation too (just watch for bits, should be 32), however did not check myself.

我相信它也适用于完整的 Oracle 客户端安装(只需注意位,应该是 32),但是我没有检查自己。

Unfortunately, Windows build of ocpdoes not have a fancy progress meter during file transfer. That piece of code had too much *nix-specific stuff, so I had to cut it off.

不幸的是,Windows 版本ocp在文件传输过程中没有花哨的进度表。那段代码有太多 *nix 特定的东西,所以我不得不把它剪掉。

Also, since it uses popt and zlib libraries, which are compiled as a part of GnuWin project, and available in 32-bit only, ocpfor Windows is 32-bit only too. Hopefully, not having of a 64-bit version is not mission critical to you.

此外,由于它使用 popt 和 zlib 库,它们被编译为 GnuWin 项目的一部分,并且仅在 32 位中可用,因此ocp对于 Windows 来说也仅是 32 位。希望没有 64 位版本对您来说不是关键任务。

Update 2:

更新 2:

Warning!Make sure you always use DEDICATED server connection when download files from server, otherwise (for SHARED server) the downloaded copy of the file will be corrupted with no error messages!

警告!从服务器下载文件时,请确保始终使用专用服务器连接,否则(对于共享服务器)下载的文件副本将被损坏且没有错误消息!

回答by Stephen ODonnell

With a bit of a hack you can get data pump to do what you want, but you need to have a database on your local machine.

通过一些技巧,您可以让数据泵做您想做的事情,但是您需要在本地计算机上拥有一个数据库。

What you need to do is create a database link on your local machine to the remote machine.

您需要做的是在本地机器上创建一个到远程机器的数据库链接。

Then in the datapump options, login to the local database as the db link owner, specify the 'network_link' option to be the name of the database link name you created. That way it should export from the remote database through the local database and create the file on your local instance. For example:

然后在datapump选项中,以db link owner身份登录本地数据库,指定'network_link'选项为你创建的数据库链接名。这样它应该通过本地数据库从远程数据库导出并在本地实例上创建文件。例如:

expdp directory=<local_dir_object> network_link=<dblinkname on local instance> dumpfile=.. logfile=.. tables/schema=...

回答by someuser2

No, data pump sucks that way, but Oracle can get faster throughput using the same server the db sits on, so thats the tradeoff. Other enhancements too, but I still think this is a big disadvantage for data pump. Use old exp/imp or third party tools for this purpose.

不,数据泵很糟糕,但是 Oracle 可以使用数据库所在的同一服务器获得更快的吞吐量,所以这就是权衡。其他增强功能也是如此,但我仍然认为这是数据泵的一大缺点。为此,请使用旧的 exp/imp 或第三方工具。

回答by Bjarte Brandt

You should ask yourself: "Why do I want to keep data outside the database - the most secure place for my data? Where backup,restore and recovery is in place.

您应该问自己:“为什么我要将数据保存在数据库之外——这是我的数据最安全的地方?备份、还原和恢复在哪里。

If you are going to move data from database A to database B, make sure both databases have access to a common file-area where they can access the datadump-files through their directory-object and use the datapump.

如果您要将数据从数据库 A 移动到数据库 B,请确保两个数据库都可以访问公共文件区域,在那里它们可以通过目录对象访问数据转储文件并使用数据泵。

If you still want to export data to client side you can use the good old tools expand imp.

如果您仍然想将数据导出到客户端,您可以使用很好的旧工具expimp