Search code examples
oracleoracle-sqldeveloperexport-to-csv

How to export an Oracle Table Chunk-wise to CSV?


I'm having a large Oracle table that has more than 10 million records. Due to download limitations, I need to export the oracle table by set by sets to CSV. Is there any way to download the table chunk-wise? Note: I'm using Oracle 11g and Oracle SQL Developer


Solution

  • I found the solution that I was looking for given by @hkandapal

    If the limit is 1 million, then you can write 10 SQL's and export to a csv.

    set linesize 2
    set numwidth 5enter code here 
    spool File1.csv 
    SELECT * FROM ( SELECT t.*, rownum rnum FROM table t order by primary_key ) WHERE rnum>= 1 
     and rnum < 1000000 -- For the 2nd query start with rnum > 999999 and < then 200000 
    spool off