sqlldr的介绍
SQL*LOADER是ORACLE的数据加载工具,通常用来将操作系统文件(数据)迁移到ORACLE数据库中。SQL*LOADER是大型数据仓库选择使用的加载方法,因为它提供了最快速的途径(DIRECT,PARALLEL)。
sqlldr的执行(在UNIX下用shell来调用)
$ORACLE_HOME/bin/sqlldr dwh/cognos@ORA8 control=../l
$ORACLE_HOME/bin/sqlldr dwh/cognos@ORA8 control=../l direct=true log=...
制定控制文件l
1、控制文件标识
2、要输入的数据文件名为
3、向表test中(追加)记录
4、指定分隔符
load data
SQL*LOADER是ORACLE的数据加载工具,通常用来将操作系统文件(数据)迁移到ORACLE数据库中。SQL*LOADER是大型数据仓库选择使用的加载方法,因为它提供了最快速的途径(DIRECT,PARALLEL)。
sqlldr的执行(在UNIX下用shell来调用)
$ORACLE_HOME/bin/sqlldr dwh/cognos@ORA8 control=../l
$ORACLE_HOME/bin/sqlldr dwh/cognos@ORA8 control=../l direct=true log=...
制定控制文件l
1、控制文件标识
2、要输入的数据文件名为
3、向表test中(追加)记录
4、指定分隔符
load data
infile '/query5/Ascential/data/month/mgmid.200304M'
into table DC_RPT_T_MGMID_200304M_30 append(APPEND为追加方式,或REPLACE)
fields terminated by ','
(
userid,
svcnum,
brand,
svcPlan,
busist,
hvcFlag,
mntFlag,
userYear,
joinMonth,
callfee,
into table DC_RPT_T_MGMID_200304M_30 append(APPEND为追加方式,或REPLACE)
fields terminated by ','
(
userid,
svcnum,
brand,
svcPlan,
busist,
hvcFlag,
mntFlag,
userYear,
joinMonth,
callfee,
callfeefav,
tollfee,
tollfeefav,
calltimes,
callduration,
billduration,
tollduration,
totalFee,
groupID
)
tollfee,
tollfeefav,
calltimes,
callduration,
billduration,
tollduration,
totalFee,
groupID
)
导入方式
************* 以下是4种装入表的方式
APPEND // 原先的表有数据 就加在后面
INSERT // 装载空表 如果原先的表有数据 sqlloader会停止 默认值
REPLACE // 原先的表有数据 原先的数据会全部删除
************* 以下是4种装入表的方式
APPEND // 原先的表有数据 就加在后面
INSERT // 装载空表 如果原先的表有数据 sqlloader会停止 默认值
REPLACE // 原先的表有数据 原先的数据会全部删除
TRUNCATE // 指定的内容和replace的相同 会用truncate语句删除现存数据
导入日期型字段
LOAD DATA
INFILE 'zlx.TXT'
append INTO TABLE zlx
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
ID,
L,
F,
M,
DATE1 date 'dd-mm-yyyy'
)
LOAD DATA
INFILE 'zlx.TXT'
append INTO TABLE zlx
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
ID,
L,
F,
M,
DATE1 date 'dd-mm-yyyy'
)
SQLLoader将 Excel 数据导出到 Oracle
1.创建SQL*Loader输入数据所需要的文件,均保存到C:,用记事本编辑控制文件:l,内容如下:
load data --1、控制文件标识
infile '' --2、要输入的数据文件名为
append into table test --3、向表test中追加记录
fields terminated by X'09' --4、字段终止于X'09',是一个制表符(TAB)
(id,username,password,sj) -----定义列对应顺序
load data --1、控制文件标识
infile '' --2、要输入的数据文件名为
append into table test --3、向表test中追加记录
fields terminated by X'09' --4、字段终止于X'09',是一个制表符(TAB)
(id,username,password,sj) -----定义列对应顺序
2.还有一种方法
可以把EXCEL文件另存为CSV(逗号分隔)(*.csv),控制文件就改为用逗号分隔
LOAD DATA
INFILE 'd:car.csv'
APPEND INTO TABLE t_car_temp
FIELDS TERMINATED BY ‘,’
(phoneno,vip_car)
可以把EXCEL文件另存为CSV(逗号分隔)(*.csv),控制文件就改为用逗号分隔
LOAD DATA
INFILE 'd:car.csv'
APPEND INTO TABLE t_car_temp
FIELDS TERMINATED BY ‘,’
(phoneno,vip_car)
在控制文件中直接导入数据
1、控制文件l的内容
LOAD DATA
INFILE *
BADFILE 'C:Documents and SettingsJackey桌面WMCOUNTRY.BAD'
INSERT INTO TABLE EMCCOUNTRY
Fields terminated by ‘;’ Optionally enclosed by '"'
(
COUNTRYID,
COUNTRYCODE,
COUNTRYNAME,
CONTINENTID ,
MAPID ,
CREATETIME DATE ‘MM/DD/YYYY HH24:MI:SS’
LASTMODIFIEDTIME DATE ‘MM/DD/YYYY HH24:MI:SS’
1、控制文件l的内容
LOAD DATA
INFILE *
BADFILE 'C:Documents and SettingsJackey桌面WMCOUNTRY.BAD'
INSERT INTO TABLE EMCCOUNTRY
Fields terminated by ‘;’ Optionally enclosed by '"'
(
COUNTRYID,
COUNTRYCODE,
COUNTRYNAME,
CONTINENTID ,
MAPID ,
CREATETIME DATE ‘MM/DD/YYYY HH24:MI:SS’
LASTMODIFIEDTIME DATE ‘MM/DD/YYYY HH24:MI:SS’
)
BEGINDATA
1;"JP";"Japan";1;9;"09/16/2004 16:31:32";
2;"CN";"China";1;10;"09/16/2004 16:31:32";
3;"IN";"India";1;11;"09/16/2004 16:31:32";
4;"AU";"Australia";6;12;"09/16/2004 16:31:32";
5;"CA";"Canada";4;13;"09/16/2004 16:31:32";
6;"US";"United States";4;14;"09/16/2004 16:31:32";
7;"MX";"Mexico";4;15;"09/16/2004 16:31:32";
8;"GB";"United Kingdom";3;16;"09/16/2004 16:31:32";
9;"DE";"Germany";3;17;"09/16/2004 16:31:32";
10;"FR";"France";3;18;"09/16/2004 16:31:32";
11;"IT";"Italy";3;19;"09/16/2004 16:31:32";
12;"ES";"Spain";3;20;"09/16/2004 16:31:32";truncate多张表加逗号吗
13;"FI";"Finland";3;21;"09/16/2004 16:31:32";
BEGINDATA
1;"JP";"Japan";1;9;"09/16/2004 16:31:32";
2;"CN";"China";1;10;"09/16/2004 16:31:32";
3;"IN";"India";1;11;"09/16/2004 16:31:32";
4;"AU";"Australia";6;12;"09/16/2004 16:31:32";
5;"CA";"Canada";4;13;"09/16/2004 16:31:32";
6;"US";"United States";4;14;"09/16/2004 16:31:32";
7;"MX";"Mexico";4;15;"09/16/2004 16:31:32";
8;"GB";"United Kingdom";3;16;"09/16/2004 16:31:32";
9;"DE";"Germany";3;17;"09/16/2004 16:31:32";
10;"FR";"France";3;18;"09/16/2004 16:31:32";
11;"IT";"Italy";3;19;"09/16/2004 16:31:32";
12;"ES";"Spain";3;20;"09/16/2004 16:31:32";truncate多张表加逗号吗
13;"FI";"Finland";3;21;"09/16/2004 16:31:32";
14;"SE";"Sweden";3;22;"09/16/2004 16:31:32";
15;"IE";"Ireland";3;23;"09/16/2004 16:31:32";
16;"NL";"Netherlands";3;24;"09/16/2004 16:31:32";
17;"DK";"Denmark";3;25;"09/16/2004 16:31:32";
18;"BR";"Brazil";5;85;"09/30/2004 11:25:43";
19;"KR";"Korea, Republic of";1;88;"09/30/2004 11:25:43";
20;"NZ";"New Zealand";6;89;"09/30/2004 11:25:43";
21;"BE";"Belgium";3;79;"09/30/2004 11:25:43";
22;"AT";"Austria";3;78;"09/30/2004 11:25:43";
23;"NO";"Norway";3;82;"09/30/2004 11:25:43";
24;"LU";"Luxembourg";3;81;"09/30/2004 11:25:43";
25;"PT";"Portugal";3;83;"09/30/2004 11:25:43";
26;"GR";"Greece";3;80;"09/30/2004 11:25:43";
27;"IL";"Israel";1;86;"09/30/2004 11:25:43";
28;"CH";"Switzerland";3;84;"09/30/2004 11:25:43";
15;"IE";"Ireland";3;23;"09/16/2004 16:31:32";
16;"NL";"Netherlands";3;24;"09/16/2004 16:31:32";
17;"DK";"Denmark";3;25;"09/16/2004 16:31:32";
18;"BR";"Brazil";5;85;"09/30/2004 11:25:43";
19;"KR";"Korea, Republic of";1;88;"09/30/2004 11:25:43";
20;"NZ";"New Zealand";6;89;"09/30/2004 11:25:43";
21;"BE";"Belgium";3;79;"09/30/2004 11:25:43";
22;"AT";"Austria";3;78;"09/30/2004 11:25:43";
23;"NO";"Norway";3;82;"09/30/2004 11:25:43";
24;"LU";"Luxembourg";3;81;"09/30/2004 11:25:43";
25;"PT";"Portugal";3;83;"09/30/2004 11:25:43";
26;"GR";"Greece";3;80;"09/30/2004 11:25:43";
27;"IL";"Israel";1;86;"09/30/2004 11:25:43";
28;"CH";"Switzerland";3;84;"09/30/2004 11:25:43";
29;"A1";"Anonymous Proxy";0;0;"09/30/2004 11:25:43";
30;"A2";"Satellite Provider";0;0;"09/30/2004 11:25:43";
31;"AD";"Andorra";3;0;"09/30/2004 11:25:43";
32;"AE";"United Arab Emirates";1;0;"09/30/2004 11:25:43";
33;"AF";"Afghanistan";1;0;"09/30/2004 11:25:43";
34;"AG";"Antigua and Barbuda";7;0;"09/30/2004 11:25:43";
35;"AI";"Anguilla";7;0;"09/30/2004 11:25:43";
36;"AL";"Albania";3;0;"09/30/2004 11:25:43";
37;"AM";"Armenia";3;0;"09/30/2004 11:25:43";
38;"AN";"Netherlands Antilles";3;0;"09/30/2004 11:25:43";
39;"AO";"Angola";2;0;"09/30/2004 11:25:43";
40;"AP";"Asia/Pacific Region";2;0;"09/30/2004 11:25:43";
41;"AQ";"Antarctica";8;0;"09/30/2004 11:25:43";
42;"AR";"Argentina";5;0;"09/30/2004 11:25:43";
43;"AS";"American Samoa";6;0;"09/30/2004 11:25:43";
30;"A2";"Satellite Provider";0;0;"09/30/2004 11:25:43";
31;"AD";"Andorra";3;0;"09/30/2004 11:25:43";
32;"AE";"United Arab Emirates";1;0;"09/30/2004 11:25:43";
33;"AF";"Afghanistan";1;0;"09/30/2004 11:25:43";
34;"AG";"Antigua and Barbuda";7;0;"09/30/2004 11:25:43";
35;"AI";"Anguilla";7;0;"09/30/2004 11:25:43";
36;"AL";"Albania";3;0;"09/30/2004 11:25:43";
37;"AM";"Armenia";3;0;"09/30/2004 11:25:43";
38;"AN";"Netherlands Antilles";3;0;"09/30/2004 11:25:43";
39;"AO";"Angola";2;0;"09/30/2004 11:25:43";
40;"AP";"Asia/Pacific Region";2;0;"09/30/2004 11:25:43";
41;"AQ";"Antarctica";8;0;"09/30/2004 11:25:43";
42;"AR";"Argentina";5;0;"09/30/2004 11:25:43";
43;"AS";"American Samoa";6;0;"09/30/2004 11:25:43";
44;"AW";"Aruba";5;0;"09/30/2004 11:25:43";
45;"AZ";"Azerbaijan";1;0;"09/30/2004 11:25:43";
46;"BA";"Bosnia and Herzegovina";3;0;"09/30/2004 11:25:43";
47;"BB";"Barbados";5;0;"09/30/2004 11:25:43";
48;"BD";"Bangladesh";1;0;"09/30/2004 11:25:43";
49;"BF";"Burkina Faso";2;0;"09/30/2004 11:25:43";
50;"BG";"Bulgaria";3;0;"09/30/2004 11:25:43";
51;"BH";"Bahrain";1;0;"09/30/2004 11:25:43";
52;"BI";"Burundi";2;0;"09/30/2004 11:25:43";
53;"BJ";"Benin";2;0;"09/30/2004 11:25:43";
54;"BM";"Bermuda";4;0;"09/30/2004 11:25:43";
55;"BN";"Brunei Darussalam";1;0;"09/30/2004 11:25:43";
56;"BO";"Bolivia";5;0;"09/30/2004 11:25:43";
57;"BS";"Bahamas";7;0;"09/30/2004 11:25:43";
58;"BT";"Bhutan";1;0;"09/30/2004 11:25:43";
45;"AZ";"Azerbaijan";1;0;"09/30/2004 11:25:43";
46;"BA";"Bosnia and Herzegovina";3;0;"09/30/2004 11:25:43";
47;"BB";"Barbados";5;0;"09/30/2004 11:25:43";
48;"BD";"Bangladesh";1;0;"09/30/2004 11:25:43";
49;"BF";"Burkina Faso";2;0;"09/30/2004 11:25:43";
50;"BG";"Bulgaria";3;0;"09/30/2004 11:25:43";
51;"BH";"Bahrain";1;0;"09/30/2004 11:25:43";
52;"BI";"Burundi";2;0;"09/30/2004 11:25:43";
53;"BJ";"Benin";2;0;"09/30/2004 11:25:43";
54;"BM";"Bermuda";4;0;"09/30/2004 11:25:43";
55;"BN";"Brunei Darussalam";1;0;"09/30/2004 11:25:43";
56;"BO";"Bolivia";5;0;"09/30/2004 11:25:43";
57;"BS";"Bahamas";7;0;"09/30/2004 11:25:43";
58;"BT";"Bhutan";1;0;"09/30/2004 11:25:43";
59;"BV";"Bouvet Island";5;0;"09/30/2004 11:25:43";
60;"BW";"Botswana";2;0;"09/30/2004 11:25:43";
61;"BY";"Belarus";3;0;"09/30/2004 11:25:43";
2、执行导入命令
C:>sqlldr userid=system/manager l
60;"BW";"Botswana";2;0;"09/30/2004 11:25:43";
61;"BY";"Belarus";3;0;"09/30/2004 11:25:43";
2、执行导入命令
C:>sqlldr userid=system/manager l
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论