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 ?

2
  • 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. stackoverflow.com/help/how-to-ask Commented Jul 3, 2019 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. Commented Jul 3, 2019 at 13:30

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.