且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用sql将数据从文件csv导入到Oracle

更新时间:2022-11-02 20:46:51

您需要使用sqlldr实用程序来加载数据。首先根据您的要求创建一个控制文件(以.ctl的扩展名结尾),如下所述。

You need to use sqlldr utility in order to load data. Firstly create a control file (ends with an extension of .ctl) as per your requirements like mentioned below.

load data
infile 'path_where_file_is_placed_followed_by_file_name'
into table table_name_where_you_want_to_insert_the_data_of_csv_file
fields terminated by ','  lines terminated by '\n' 
(
field1 datatype,
field2 datatype,
field3 datatype
)

现在执行sqlldr实用程序。

Now execute sqlldr utility to load data as mentioned below.

sqlldr userid=database_username/password@instance_name control=path_where_control_file_is_placed_followed_by_control_file_name LOG=path_for_log_file BAD=path_for_bad_records Discard=path_for_discard_records