Oracle sql 结果到 DBF 文件导出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2125211/
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-18 19:51:38  来源:igfitidea点击:

Oracle sql result to DBF file export

oracledbf

提问by Mkrish

I would like to export data from a Oracle table into *.dbf file (like excel) through PL/SQL scripts. Are there any codes available?

我想通过 PL/SQL 脚本将 Oracle 表中的数据导出到 *.dbf 文件(如 excel)中。有没有可用的代码?

回答by APC

There are a number of different ways to do this. The easiest way is to use an IDE like SQL Developer or TOAD, which offer this functionality.

有许多不同的方法可以做到这一点。最简单的方法是使用提供此功能的 IDE,如 SQL Developer 或 TOAD。

If you want to call it from PL/SQL, then then are no built-in Oracle functions. However, it is relatively straightforward to build something using UTL_FILE which can write out value separated records. These can be picked up in Excel.

如果您想从 PL/SQL 调用它,则没有内置的 Oracle 函数。但是,使用可以写出值分隔记录的 UTL_FILE 构建一些东西相对简单。这些可以在 Excel 中提取。

Note that the default separator - ,(comma being the "C" in .CSV) - will cause problems if your exported data contains commas. So you will need to use the Data Import wizard rather than a right-click Open With ...

请注意,,如果导出的数据包含逗号,则默认分隔符(逗号是 .CSV 中的“C”)会导致问题。因此,您将需要使用数据导入向导,而不是右键单击打开方式...

Incidentally, it is probably a bad idea to use the .dbfsuffix. In an Oracle file system the presumed meaning is database file - i.e. part of the database's infrastructure. This is just a convention, but there is no point in needlessly confusing people. Perferred alternatives include .csv, .dmpor .exp.

顺便说一句,使用.dbf后缀可能是个坏主意。在 Oracle 文件系统中,假定的含义是数据库文件——即数据库基础设施的一部分。这只是一个约定,但没有必要不必要地混淆人们。首选的替代方案包括.csv.dmp.exp

edit

编辑

If your interest is just to export data for transferring to another Oracle database then you should look at using the Data Pump utility. This comes with an API so it can be used from PL/SQL. Alternatively we unload data through external tables declared with a DataPump driver.

如果您只想导出数据以传输到另一个 Oracle 数据库,那么您应该考虑使用数据泵实用程序。它带有一个 API,因此可以从 PL/SQL 中使用它。或者,我们通过使用 DataPump 驱动程序声明的外部表卸载数据。

回答by PenFold

You could also consider using the External Tables feature of Oracle. This essentially allows you to map a CSV file to a 'virtual' table and the you can insert into it (and therefore the file.)

您还可以考虑使用 Oracle 的外部表功能。这基本上允许您将 CSV 文件映射到“虚拟”表,并且您可以将其插入(以及文件)。

Oracle External Tables Concept Guide

Oracle 外部表概念指南