Export, based on query, into INSERT text file

dumpexportimportoracle

I need to export some data into a file. The data are selected with a query that will often be made of multiple joins. I want the import operation to be as easy as possible. I was thinking of building an INSERT file with such a method:
Oracle PL/SQL: Dump query result into file

But I am wondering if there is some tool already existing to export data based on a query. If this is the case, I might as well be happy with some binary file, as long as importing this file afterward is straight forward.
I see there is exp, but it doesn't seem to really be able to handle queries, only basic WHERE clauses.

Best Answer

Have you looked into using the UTL_FILE package ? Using that, you can write to ( and read from ) files really easily and directly from PL/SQL, with great robustness. You need to configure a Directory object in your database, and then you can write to it with ease.

Here's some material on the subject : http://psoug.org/reference/utl_file.html , http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/u_file.htm