0

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 ?

  • too broad - Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. https://stackoverflow.com/help/how-to-ask – Rob Jul 03 '19 at 13:04
  • I'd export it as a single file and then after-the-fact, use your bash wizardry to chunk up the file as small as you'd like. – thatjeffsmith Jul 03 '19 at 13:30

1 Answers1

2

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
Dmitry Demin
  • 2,006
  • 2
  • 15
  • 18
  • i really like this answer, it will at the end of the day be much easier than writing some oracle code to go get x rows, write them to file one, go get next x rows, write them to file, and so on... – thatjeffsmith Jul 03 '19 at 14:53