设为首页 收藏本站
查看: 1508|回复: 0

[经验分享] sqlldr load excel导入oracle#ocp试验#

[复制链接]

尚未签到

发表于 2015-6-16 12:10:25 | 显示全部楼层 |阅读模式
  源数据animal_feeding.csv
  100,1-jan-2000,23.5,"Flipper seemed unusually hungry today."
105,1-jan-2000,99.45,"Spread over three meals."
112,1-jan-2000,10,"No comment."
151,1-jan-2000,55
166,1-jan-2000,17.5,"Shorty ate Squacky."
145,1-jan-2000,0,"Squacky is no more."
175,1-jan-2000,35.5,"Paintuin skipped his first meal, but ate the other five."
199,1-jan-2000,0.5,"Nosey wasn't very hungry today."
202,1-jan-2000,22.0
240,1-jan-2000,28,"Snoops appeared lethargic, and was running a fever."
100,2-jan-2000,19.5,"Flipper's appetite has returned to normal."
105,2-jan-2000,89.0
112,2-jan-2000,12
151,2-jan-2000,50
166,2-jan-2000,16.0,"We are keeping Shorty isolated from the other animals."
175,2-jan-2000,30
199,2-jan-2000,9.5,"Nosey's appetite has returned."
202,2-jan-2000,19.3
240,2-jan-2000,22,"Snoops still lethargic, no fever."
100,3-jan-2000,16,"Flipper's appetite is on the decrease."
105,3-jan-2000,101
112,3-jan-2000,8,"Bopper was very aggressive during feeding."
151,3-jan-2000,43
166,3-jan-2000,15,"We are back to normal w/Shorty."
175,3-jan-2000,33
199,3-jan-2000,8
202,3-jan-2000,18
240,3-jan-2000,30,"Snoops is back to his normal self."
  现在要把这些数据写入scott下
  1,在scott下建表



SET ECHO ON
CREATE TABLE animal_feeding (
animal_id               NUMBER,
feeding_dateDATE,
pounds_eatenNUMBER (5,2),
noteVARCHAR2(80)
);

  2,写load的control控制文件load_exam.txt
  



load
infile 'D:\animal_feeding.csv' --源数据
append                        --覆盖写入?
into table scott.animal_feeding
trailing nullcols             --源数据没有对应,写入null
( animal_id   integer external terminated by ',', --“,”结束标记,也可以指定长度position (1:3 4:14)
feeding_date  date "dd-mon-yyyy" terminated by ',',
pounds_eaten  decima external terminated by ',',
note          char terminated by ','
optionally enclosed by '"'  --note源文件有双引号,这里去掉
)

  3,windows下的命令行导入
  这里可以指定log的文件目录
  特别注意,因为scott是oracle的默认建立,好多的实例都有scott,并且密码都是tiger,因此做之前最好set oracle_sid=sen指定
  一步到处登陆:sqlplus scott/tiger@sen



C:\Documents and Settings\dell>sqlldr scott/tiger control=d:\load_exam.txt log=d:\load_exam_log.txt

  回车报错
  SQL*Loader-350: 语法错误位于第 9 行。
预期值是 有效的列说明, "," 或 ")", 而实际值是 "decima"。
    pounds_eaten  decima external terminated by ',',

  修改
  原来是decimal少了最后的“l”
  执行,之后报错,看log
DSC0000.png
  修改系统的日期显示为american
DSC0001.png
  
  4,从scott查询这个表,得到结果,成功
DSC0002.png
  下面是日志
  
SQL*Loader: Release 11.2.0.1.0 - Production on Mon Dec 31 18:43:11 2012
  Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
  Control File:   d:\load_exam.txt
Data File:      D:\animal_feeding.csv
  Bad File:     d:\animal_feeding.bad
  Discard File:  none specified
(Allow all discards)
  Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array:     64 rows, maximum of 256000 bytes
Continuation:    none specified
Path used:      Conventional
  Table SCOTT.ANIMAL_FEEDING, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
  Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
ANIMAL_ID                           FIRST     *   ,       CHARACTER            
FEEDING_DATE                         NEXT     *   ,       DATE dd-mon-yyyy     
POUNDS_EATEN                         NEXT     *   ,       CHARACTER            
NOTE                                 NEXT     *   ,  O(") CHARACTER            
  
Table SCOTT.ANIMAL_FEEDING:
  28 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.
  
Space allocated for bind array:                  66048 bytes(64 rows)
Read   buffer bytes: 1048576
  Total logical records skipped:          0
Total logical records read:            28
Total logical records rejected:         0
Total logical records discarded:        0
  Run began on Mon Dec 31 18:43:11 2012
Run ended on Mon Dec 31 18:43:11 2012
  Elapsed time was:     00:00:00.18
CPU time was:         00:00:00.00
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-77936-1-1.html 上篇帖子: OCP—051试题 下篇帖子: OCP读书笔记(8)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表