开发者

Oracle sql result to DBF file export

开发者 https://www.devze.com 2022-12-18 02:37 出处:网络
I would like to export data from a Oracle table into *.dbf file (like excel) through PL/SQL scripts. Are there any codes开发者_StackOverflow社区 available?There are a number of different ways to do th

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


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.

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.

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 ...

Incidentally, it is probably a bad idea to use the .dbf suffix. 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, .dmp or .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.


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 External Tables Concept Guide

0

精彩评论

暂无评论...
验证码 换一张
取 消