How to insert data directly from Excel to Oracle Database

前端 未结 5 871
无人共我
无人共我 2021-01-03 16:32

I would like to know how to insert data from Excel to Oracle meaning lets say i have a worksheet full of data and i want to insert them all into Oracle database.

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 17:01

    convert your excel file format to .csv format with using save as option

    Save below content in a file with .ctl extension in the D drive under folder_name folder. Before running this .ctl make sure that table should be present in your schema with the distinct column names not like in your posted image. And the column name should be match with names of .ctl file(sc_id, sal, etc). And the datatypes of your columns should be match with the data present in a .csv file. And also make sure that your table should be empty otherwise you should use truncate or append options in your .ctl file.

     LOAD DATA
        INFILE 'D:\folder_name\csvfile_name.CSV'
        BADFILE 'D:\folder_name\csvfile_name.BAD'
        DISCARDFILE 'D:\folder_name\csvfile_name.log'
        logfile 'D:\folder_name\csvfile_name.DSC'
        iNTO TABLE schema_name.table_name
        FIELDS TERMINATED BY ','
        TRAILING NULLCOLS
    
        (
        sc_id,
        sal,
        sc_cd1,
        coll,
        sc_cd2,
        bill_mas,
       sc_cd3,
       wk_sal,
       check_bill_month,
       check_sale_wk
        ) 
    

    Run your .ctl file in sql plus with use of below commands

    sqlldr schema_name/password@databasename control=your control file path.
    

    If any error occurs while loading data into table those will logged into .log file. For learn more about sqlloader Refer http://docs.oracle.com/cd/B10501_01/server.920/a96652/ch05.htm

提交回复
热议问题