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
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
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.