How do I spool to a CSV formatted file using SQLPLUS?

csv, oracle, sql, sqlplus

Solution

If you are using 12.2, you can simply say

set markup csv on
spool myfile.csv

Problem

I want to extract some queries to a CSV output format. Unfortunately, I can't use any fancy SQL client or any language to do it. I must use SQLPLUS. How do I do it?

Original source