Create flat file with Oracle SQL*Plus To create a flat file with Oracle SQL*Plus you can use the spool command. However it requires a little knowledge of the SQL*Plus commands to get exactly the information in the file that is required. As of standard SQL*Plus will repeat the query being executed, display a feedback line and column titles. If none of that is required and ONLY the data is required to be put in the text file the following command file can be used.
Type the following commands in a plain text file and call it test.sql
Code:
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
spool output.txt;
select sysdate from dual;
spool off;
To run this command type this command in SQL*Plus:
@run
Now inspect the file output.txt the command produced. Only the data is sent to the file and nothing else!