views:

3634

answers:

1

Hi,

I was wondering how to go about exporting a query from PL/SQL to an text file or csv file. The query I have in mind exports a huge amount of data (about 1 gig). So I'd also like the data split across multiple files;

out1.csv out2.csv out3.csv

I'd like to be able to decide how many files to split it across.

Anyone have any idea how to do this?

Cheers Rich

+2  A: 

Use UTL_FILE.

A well known ( probably the most complete discussion on this topic ) discussion on this can be found at Ask Tom, Here , note that many of the examples there date back to oracle 8, so there may be better ways to do it in your version of Oracle.

Matthew Watson
I'm that familiar with Oracle and PL/SQL could you please give a litte more detail?
Rich
Should read 'I'm NOT that familiar ...'
Rich
Yep, I was looking for more info, but couldn't find it.. then realised that its UTL_FILE, not DBMS_FILE. I've linked the package spec. Its just a package for reading/writing files to disk
Matthew Watson
Cool thanks, however I still need to work out how to direct the output to the file and how to perform the spanning.
Rich