Q
Problem solve Get help with specific problems with your technologies, process and projects.

Writing data to flat files without UTL_FILE

How can I write the data in my Oracle database onto flat files without using the UTL_FILE package.

There are a couple of ways you can accomplish this. First, you can write just a straight SQL script. For example, assume MY_TABLE has three columns, COL1, COL2, COL3. Then, I can do the following in SQL*Plus:

set heading off
set feedback off
set pagesize 0
spool /somedir/my_file.csv
SELECT col1||','||col2||','||col3 FROM my_table;
spool off

If you don't want to run this through SQL*Plus, and you wish to automate it in some way (like through a stored procedure), then UTL_FILE is one way to write directly to a file. Otherwise, you'll have to write an external C routine, or run Java in the database to write to a file.

For More Information


You'll have to enumerate every column in this manner. Alternatively, the DBMS_UTILITY supplied package has a TABLE_TO_COMMA procedure which will perform the same essential function.

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close