To prevent the select statement from appearing as the first line in your CSV output, you can modify your script as follows:
SET HEADING OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SET ECHO OFF
SET VERIFY OFF
SET TERMOUT OFF
SET TRIMSPOOL ON
SPOOL c:\test.csv
SELECT /*csv*/ username, user_id, created FROM all_users;
SPOOL OFF
Here's an explanation of the additional SET commands:
- SET HEADING OFF: This command turns off the column headings in the output.
- SET FEEDBACK OFF: This command suppresses the "X rows selected" message.
- SET PAGESIZE 0: This command sets the page size to 0, which means no pagination.
- SET ECHO OFF: This command turns off the echoing of commands in the output.
- SET VERIFY OFF: This command turns off the verification of the substitution variables.
- SET TERMOUT OFF: This command turns off the terminal output.
- SET TRIMSPOOL ON: This command trims the trailing spaces from each line in the spool file.
By using these SET commands, you should be able to generate a clean CSV file without the select statement appearing as the first line.