ITPub博客

首页 > 数据库 > Oracle > SQL loader 导入csv格式的表格文件的一个例子

SQL loader 导入csv格式的表格文件的一个例子

原创 Oracle 作者:genweihua 时间:2012-08-28 09:02:15 0 删除 编辑

一、准备数据 da.csv

1 geng

2 luo

3 yang

4 lu

二、建立表结构

create table study(no int,name varchar2(20);

commit;

三、建立控制文件 control.ctl (csv中的数据是以,分割的)

load data
infile 'F:\study\da.csv'
into table study
fields terminated by ','
(no,name)

四、导入数据:F:\study 路径为sqlloader控制文件和日志文件路径

sqlldr userid=study/windows@study control=F:\study\control.c
tl log=F:\study\l.log

下边是在CMD下执行的过程:

C:\Windows\system32>sqlplus /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 8月 28 09:11:15 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn system/windows@study
已连接。

SQL> create user study identified by windows default tablespace studydata;

用户已创建。

SQL> grant dba to study;

授权成功。

SQL> commit;

提交完成。

SQL> conn study/windows@study
已连接。
SQL> create table study(no int,name varchar2(20));

表已创建。

SQL> commit;

提交完成。

SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开

C:\Windows\system32>sqlldr userid=study/windows@study control=F:\study\control.c
tl log=F:\study\l.log

SQL*Loader: Release 10.2.0.4.0 - Production on 星期二 8月 28 09:18:21 2012

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

达到提交点 - 逻辑记录计数 4

C:\Windows\system32>sqlplus /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 8月 28 09:18:39 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn study/windows@study
已连接。
SQL> select * from study;

        NO NAME
---------- ----------------------------------------
         1 geng
         2 luo
         3 na
         4 wu

SQL>

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22275400/viewspace-742035/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 表空间管理
请登录后发表评论 登录
全部评论
事了拂衣去,深藏功与名!

注册时间:2009-08-28

  • 博文量
    114
  • 访问量
    624107