Question: how to export data from oracle table to csv file using pl/sql?
Answer: To create a file, we need to create a directory and have the read write permission as.
1) create or replace directory MYCSV as '/home/oracle/mycsv';
Note: /home/oracle/mycsv has to be physical location on disk.
2) grant read, write on directory MYCSV to scott;
Following is the pl/sql sample code to create CSV file.