Muhammad Kashif Ali
Muhammad Kashif Ali

Reputation: 11

How to Export Oracle Table Data in CSV Separate Files Using SQL Developer

I have have oracle database table and having 20000000 records. I want to export data in multiple files. I am using Oracle SQL Developer. Can any one please help me how can I export data as per my requirement or suggest man an open source tool ?

Upvotes: 0

Views: 2535

Answers (1)

Dmitry Demin
Dmitry Demin

Reputation: 2113

You can split a text file using PowerShell or linux shell.

How to Split Large Text File into Smaller Files in Linux

  • example for linux

    #split -l 100000 test.txt new

  • example for Windows

How can I split a text file using PowerShell?

split_log.ps1
    param(
    [string]$input_file = "",
    [string]$count_line = ""
    )
    $lineCount = 0
    $fileCount = 1

    foreach ($line_file in get-content $input_file)
    {
        write $line_file | out-file -encoding ASCII -Append $input_file"_"$fileCount".out"
        $lineCount++

        if ($lineCount -eq $count_line)
        {
            $fileCount++
            $lineCount = 0
        }
    }




       PS C:\АСУ\Stackoverflow\split_log> ls


    Каталог: C:\АСУ\Stackoverflow\split_log


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        17.12.2018      6:03   10959355 1124.sql
-a---        17.12.2018      7:27        357 split_log.ps1


PS C:\АСУ\Stackoverflow\split_log> .\split_log.ps1 .\1124.sql 10000
PS C:\АСУ\Stackoverflow\split_log> ls


    Каталог: C:\АСУ\Stackoverflow\split_log


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        17.12.2018      6:03   10959355 1124.sql
-a---        17.12.2018      7:50    2461667 1124.sql_1.out
-a---        17.12.2018      7:50    2461458 1124.sql_2.out
-a---        17.12.2018      7:50    2461340 1124.sql_3.out
-a---        17.12.2018      7:50    2461352 1124.sql_4.out
-a---        17.12.2018      7:50    1113540 1124.sql_5.out
-a---        17.12.2018      7:27        357 split_log.ps1

Upvotes: 2

Related Questions