Improve company productivity with a Business Account.Sign Up


Text File generation in oracle

Posted on 2013-06-18
Medium Priority
Last Modified: 2013-06-29
Can anybody tell me, how to generate text file in oracle without using UTL_FILE_DIR ?
Question by:gotetioracle
LVL 14

Assisted Solution

by:Alexander Eßer [Alex140181]
Alexander Eßer [Alex140181] earned 1000 total points
ID: 39255509

see chapter "Unloading data into an external file..."

Author Comment

ID: 39255665
hi Alex140181,

I want to generate a text file from the sql query output without using  UTL_FILE_DIR .

LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39255671
Did you READ the chapter from my link above?!? -> no use of UTL_FILE
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.


Author Comment

ID: 39255787
i read but the document does not tell how to write a data from a table to a csv file.
LVL 36

Expert Comment

ID: 39255953
I'm a little confused.  Are you trying to avoid using the UTL_FILE_DIR parameter, or the UTL_FILE package.

You can use UTL_FILE without setting UTL_FILE_DIR.  You just have to have a directory object within Oracle that points to the directory where you want the file to be placed.  They are created with the CREATE DIRECTORY command.  Doc for CREATE DIRECTORY ->
LVL 79

Accepted Solution

slightwv (䄆 Netminder) earned 1000 total points
ID: 39256004
There is always sqlplus and the spool command.

There are several ways to generate a CSV.  If you are using 11G, I suggest the LISTAGG function.

If not, I suggest the XMLAGG approach:

There are more listed here:

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question