1)sqlldr
1@@@@most simple and typical example.
@@@
@@@<1>write the control file and make a source datafile.
@@@
@@@Create the dir first on your file system by oracle.
@@@In this case, I use password of the file system.
[oracle@station78 ~ ]$ mkdir -p /home/oracle/test
[oracle@station78 test]$ pwd
/home/oracle/test
@@@login by root.
[root@station78 ~]# cat /etc/passwd >> /home/oracle/test/sqlldr01.dat
@@@login by oracle back.
[oracle@station78 test]$ cat sqlldr01.dat | head -n 3
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
@@@
@@@<2>create directory object, then grant.
@@@
[oracle@station78 ~]$ sqlplus / as sysdba;
SYS@ocp> create directory dir01 as '/home/oracle/test';
Directory created.
SYS@ocp> grant read,write on directory dir01 to hr;
Grant succeeded.
@@@
@@@<3>create corresponding table.
@@@
SYS@ocp> conn hr/hr
Connected
HR@ocp> ed
1 create table sqlldr_test(
2 osname varchar2(20),
3 passwd varchar2(1),
4 userid number(8),
5 groupid number(8),
6 osfullname varchar2(40),
7 homedir varchar2(40),
8* bash varchar2(30))
HR@ocp> /
Table created.
@@@
@@@<4>write the ctl file, and loading data
@@@
[oracle@station78 test]$ pwd
/home/oracle/test
[oracle@station78 test]$ cat control01.ctl
load data
infile 'sqlldr01.dat'
into table sqlldr_test
fields terminated by ':'
(
osname char,
passwd char,
userid integer external,
groupid integer external,
osfullname integer external,
homedir char,
bash char
)
[oracle@station78 test]$ sqlldr hr/hr control=control01.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 22 15:18:47 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 60
@@@
@@@<5>check result
@@@
@@@In this case column 5th is two long.
[oracle@station78 test]$ cat sqlldr01.bad
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
pegasus:x:66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
cimsrvr:x:495:501:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
@@@
@@@the log file beside record the detail of error data.
[oracle@station78 test]$ cat control01.log
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 22 15:18:47 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: control01.ctl
Data File: sqlldr01.dat
Bad File: sqlldr01.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 SQLLDR_TEST, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
OSNAME FIRST * : CHARACTER
PASSWD NEXT * : CHARACTER
USERID NEXT * : CHARACTER
GROUPID NEXT * : CHARACTER
OSFULLNAME NEXT * : CHARACTER
HOMEDIR NEXT * : CHARACTER
BASH NEXT * : CHARACTER
Record 22: Rejected - Error on table SQLLDR_TEST, column OSFULLNAME.
ORA-12899: value too large for column "HR"."SQLLDR_TEST"."OSFULLNAME" (actual: 43, maximum: 40)
Record 42: Rejected - Error on table SQLLDR_TEST, column OSFULLNAME.
ORA-12899: value too large for column "HR"."SQLLDR_TEST"."OSFULLNAME" (actual: 41, maximum: 40)
Record 43: Rejected - Error on table SQLLDR_TEST, column OSFULLNAME.
ORA-12899: value too large for column "HR"."SQLLDR_TEST"."OSFULLNAME" (actual: 41, maximum: 40)
Record 57: Rejected - Error on table SQLLDR_TEST, column OSFULLNAME.
ORA-12899: value too large for column "HR"."SQLLDR_TEST"."OSFULLNAME" (actual: 63, maximum: 40)
Table SQLLDR_TEST:
56 Rows successfully loaded.
4 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: 115584 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 60
Total logical records rejected: 4
Total logical records discarded: 0
Run began on Wed Aug 22 15:18:47 2012
Run ended on Wed Aug 22 15:18:48 2012
Elapsed time was: 00:00:00.11
CPU time was: 00:00:00.01
sqlldr example01 basic
原创emperor_majesty 博主文章分类:Data Warehouse ©著作权
©著作权归作者所有:来自51CTO博客作者emperor_majesty的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
01-zabbix安装
centos7上面部署zabbix
mysql vim php -
Impdp and Expdp example01
oltp => filter => dw , using datapumb in oracle 10g.
oltp impdp expdp data warehouse -
dw sqlldr example02 basic
BASIC02
oracle sqlldr -
dw sqlldr example04 parallel and transformation
transformation and parallel
transformation parallel -
vue-其他basic-01.html
【代码】vue-其他basic-01.html。
css html javascript vue.js