SPOOL returns empty files when trying to export from SQL Developer

In my case, it took two things to fix the problem:

  • running from a script (using @C:\file.sql notation)
  • upgrading to the latest version of SQL Developer

I was running SQL Developer 3.2.20.09 (doesn't work), and now use 4.0.2.51 (exact same script works).

Also,


The fact that the file is created, but has no data, perhaps, the last statement, SPOOL OFF is not yet executed. Add a new line in the script and try again.

For example, your script would look like :

    spool "C:\Users\james.foreman\Downloads\Temp\myfile.csv"

    select distinct placement_type
    FROM jf_placements
    /

    spool off
    /

-- need a new line to make sure spool off executes

My problem solved after I highlight the whole script and press F5 in SQL developer .


When you run your script, press "Run Script" instead of "Run Statment" or you may press F5.

It fixed my problem, hope it can fix yours too