I need to retrieve certain data from an Oracle 11g release 1 database and provide it as one or more CSV files. The data resides in multiple tables and/or views. All this should work via the command line. What would be the best approach to this?
|
Tom Kyte has a number of different solutions to generating flat files from Oracle on his site. There is a PL/SQL implementation using UTL_FILE as well as a Pro*C SQL unloader application. |
|||
|
|
You should look at the built in UTL_FILE package. There are several ways you could use it.
In their simplest a file export using UTL_FILE would be composed of a call to FOPEN, one or more calls to PUT_LINE, and a call to FCLOSE. |
||||
|
|
|
If performance is a concern, you may want to consider tools from vendors. I have evaluated tools from BMC, Wisdomforce, CoSort, DBCrane. They are all significantly faster than spool, utl_file or external table. We are using DBCrane (http://www.bronzeage.us/downloads.html) because my boss didn't want to spend too much on license. Lei |
|||
|
|
|
Arun, easiest for this is to use APEX and export the report to csv. In plain old sqlplus you can do this by using
This works best if the results are to be written on an application server or client. If they have to be written on the database server, utl_file might be a better option. Ronald. |
||||
|
|