The PL/SQL Developer's command-line tool is a different product than Oracle SQL*Plus
command-line utility, and it has a different set of supported commands. PL/SQL Developer's command line mimics a real SQL*Plus functionality but does it only partially. For example, it doesn't support the SET MARKUP CSV
command. You can find the full list of supported commands in the PL/SQL Developer's Manual (Help -> User's Guide).
In your case, trailing spaces appear because you are printing headers of columns. Apparently, PL/SQL Developer tries to align rows by the maximum length of the column:
spool file.txt
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
OBJECT_NAME OBJECT_ID CREATED STATUS
-------------------------------------------------------------------------------- ---------- ----------- -------
TS$ 16 26.01.2017 VALID
ICOL$ 20 26.01.2017 VALID
Keeping in mind that PL/SQL Developer's supports of SET commands is very limited, we can achieve the CSV like spooling by simply not printing headers and setting colwidth to 1:
spool file.txt
set colsep |
set heading off
set colwidth 1
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
spool off
it saves this to the spool file:
TS$|16|26.01.2017 13:52:45|VALID
ICOL$|20|26.01.2017 13:52:45|VALID
C_FILE#_BLOCK#|8|26.01.2017 13:52:45|VALID
If you must print the headers, you can add an additional select from dual before the main sql just to print headers.