将来自 windows C: 驱动器的 .csv 文件中的数据插入到 oracle11g 数据库中

insert data from .csv file from windows C: drive into oracle11g database

我对此很陌生,我需要将 windows C: 驱动器上的 .csv 文件插入到 oracle11g 数据库中。 考虑使用 sql 加载程序,但不确定从哪里开始。

抱歉,我没有任何代码。

创建一个目标table(如果你没有):

M:\>sqlplus scott/tiger@orcl

SQL*Plus: Release 11.2.0.1.0 Production on Sri Tra 21 12:04:48 2021

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> create table my_table (id number, name varchar2(20));

Table created.

SQL>

示例数据文件(因为你没有 post 你的),名为 my_data.csv,位于我的 M 磁盘的根目录中(你的是 C) :

1,Little
2,Foot

控制文件(名为test37.ctl):

load data
infile 'm:\my_data.csv'
truncate into table my_table
fields terminated by ','
(id, 
 name
)

运行 SQL*从操作系统命令提示符加载程序:

M:\>sqlldr scott/tiger@orcl control=test37.ctl log=test37.log

SQL*Loader: Release 11.2.0.1.0 - Production on Sri Tra 21 12:08:40 2021

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Commit point reached - logical record count 1
Commit point reached - logical record count 2

M:\>

检查我们做了什么:

M:\>sqlplus scott/tiger@orcl

SQL*Plus: Release 11.2.0.1.0 Production on Sri Tra 21 12:09:15 2021

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select * from my_table;

        ID NAME
---------- --------------------
         1 Little
         2 Foot

SQL>