LOAD DATA INFILE equivalent in Oracle

前端 未结 2 861
野的像风
野的像风 2020-12-11 04:29

I just was wodering if there\'s an equivalent to MySQL LOAD DATA INFILE statemnent in Oracle? I need it because I want to read from a huge textfile into a database table.

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 05:17

    Example on windows 10 and Oracle 12c

    if you have a text file with records of each table delimited by comma, you can do this:

    Create a control file for each table, called table_name.ctl (C:\Users\user\Desktop\directory\table_name.ctl)

    load data 
    infile 'C:\Users\user\Desktop\directory\table_name.txt' 
    append
    into table table_name
    fields terminated by ","
    (id, field2,field3)
    

    After, In windows you should open Cmd and load data in each table, and then load data remotely for example in a aws server.

    sqlldr userid=USER@AWS_PDB1/password
    control='C:\Users\user\Desktop\directory\table_name.ctl' log='C:\Users\user\Desktop\directory\table_name.log' direct=true
    

    or

    sqlldr control='C:\Users\user\Desktop\directory\table_name.ctl' log='C:\Users\user\Desktop\directory\table_name.log' direct=true
    and then ask them the user and password
    

    If you have the following error:“The program can’t start because oranfsodm12.dll is missing from your computer. Try reinstalling the program to fix this problem.”

    it is because SQL * Loader is disabled and can not be used in the console windows, this is solved enabling the following steps (as http://www.dallasmarks.com/installing-two-oracle-12c-clients-on-one-server/):

    1. Should go to the folder C:\oracle\client\user\product\12.1.0\client_1\BIN

    2. Make a copy of oraodm12.dll file, calling the new file oranfsodm12.dll, and paste it in the same BIN folder.

    3. Run the command again from cmd.

提交回复
热议问题