Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle how to export query to a text/csv file

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?

like image 705
Rich Avatar asked May 13 '09 12:05

Rich


People also ask

How do I export SQL query results to text file?

However, if you prefer to export SQL query results to a text file via a Wizard, we have your back. To begin with, right-click the database in SQL Server Management Studio or SSMS. Then, select the Import or Export data option and head to Export Data under Tasks. Next, open the SQL Server Import and Export wizard.


1 Answers

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.

like image 160
Matthew Watson Avatar answered Sep 22 '22 16:09

Matthew Watson