load multiple csv into one table by SQLLDR

前端 未结 5 1846
闹比i
闹比i 2021-01-05 03:36

I am using SQL LOADER to load multiple csv file in one table. The process I found is very easy like

LOAD
  DATA 
  INFILE \'/path/file1.csv\'
  INFILE \'/pat         


        
相关标签:
5条回答
  • 2021-01-05 03:48

    Solution 1: Can you concatenate the 1000 files into on big file, which is then loaded by SQL*Loader. On unix, I'd use something like

    cd path
    cat file*.csv > all_files.csv
    
    0 讨论(0)
  • 2021-01-05 03:54

    You can use a wildcards (? for a single character, * for any number) like this:

    infile 'file?.csv'
    

    ;)

    0 讨论(0)
  • 2021-01-05 03:54
    OPTIONS (skip=1)
    LOAD DATA
    

    INFILE /export/home/applmgr1/chalam/Upload/*.csv

    REPLACE INTO TABLE XX_TEST_FTP_UP
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    (FULL_NAME,EMPLOYEE_NUMBER)
    

    whether it will check all the CSV and load the data or not

    0 讨论(0)
  • 2021-01-05 04:05

    Solution 2: Use external tables and load the data using a PL/SQL procedure:

    CREATE PROCEDURE myload AS
    BEGIN
      FOR i IN 1 .. 1000 LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE xtable LOCATION ('''||to_char(i,'FM9999')||'.csv'')';
        INSERT INTO mytable SELECT * FROM xtable;
      END LOOP;
    END;
    
    0 讨论(0)
  • 2021-01-05 04:10

    Loop over the files from the shell:

    #!/bin/bash
    for csvFile in `ls file*.csv`
    do
        ln -s $csvFile tmpFile.csv
        sqlldr control=file_pointing_at_tmpFile.ctl
        rm tmpFile.csv
    done
    
    0 讨论(0)
提交回复
热议问题