<p>I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this?</p>

<p>My prefered way would be by using UTL_FILE. Would some one have an example of how to do this?</p>

If you're running the query from
sqlplus
you can use the spool command:
```
spool /tmp/test.spool
```
After executing the spool command within a session, all output is sent to the sqlplus console as well as the /tmp/test.spool text file.