title: export oracle table in a csv file
body: <p>I am writting an sql script to export the content of tables in csv files (one table per file). I managed to write a successful script, thanks to the spool function like this :</p>
  
  <pre><code>spool export.csv append
  
  select 'fielda;fieldb;...' from dual
  select fielda,fieldb,....  from table
  
  spool off.
  </code></pre>
  
  <p>The first problem with this, is that I have to do a select from dual to get only the fields name on the first line.</p>
  
  <p>The second problem with this, is that I have to write each field, and it becomes very painfull when you have 10 tables each having more than 20 fields. So my question was, is there any pl sql function, that takes in parameter only the table name, and export the full content in a csv file.</p>
  
  <p>Thanks in advance.</p>