Insert a text file into Oracle with Bulk Insert

和自甴很熟 提交于 2019-12-12 04:39:20

问题


I have a place.file text file;

place.file

  • New Hampshire
  • New Jersey
  • New Mexico
  • Nevada
  • New York
  • Ohio
  • Oklahoma ....

There are 4000 place names in this file. I will match my my_place table in oracle and place.file . So I want to insert the place.file into the Oracle . Maybe I should use bulk insert, how can I do bulk insert ?


回答1:


No mention of an Oracle version. (For the best possible answer, always include Oracle version, Oracle edition, OS, and OS version.)

However, you should investigate using an external table for this purpose. Once you have that set up correctly, you can do:

insert into db_table select ... from external_table;

Optionally, you could use the APPEND hint on the INSERT statement, to use direct load. Also,optionally, you could set the NOLOGGING attribute on the table you're loading the data into, for best performance. But, consider the recovery implications before you enable NOLOGGING.

Hope that helps,

-Mark




回答2:


You can use SQL Loader from Oracle.

The syntax is:

sqlldr *connection_string* control=*control_file.ctl*

The control file contains:

LOAD DATA
INFILE names.file
INTO TABLE <table_name>
FIELDS TERMINATED BY <delimiter>
OPTIONALLY ENCLOSED BY <enclosing character>
(<column_name>[, <column_name>, <column_name>]) 


来源:https://stackoverflow.com/questions/7749947/insert-a-text-file-into-oracle-with-bulk-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!