1 f f 2010-8-19 2 f1 f1 2010-8-19 3 f2 f2 2010-8-19 4 f3 f3 2010-8-19 5 f4 f4 2010-8-19
load data infile 'c:\data.txt' insert into table ftest fields terminated by " " (id,username,password,sj)
sqlldr fyzh/fyzh control=c:\cont.ctl data=c:\data.txt
load data infile * --告诉sqlldr要加载的数据就包含在控制文件本身 into table dept --加载到哪个表 fields terminated by ',' --数据加载形式应该是逗号分隔的值 (deptno,dname,loc) --所要加载的列 begindata --告诉sqlldr后面的行市要加载到dept表的数据 10,Sales,Virginia 20,Accounting,Virginia 30,Consulting,Virginia 40,Finance,Virginia create table dept (deptno number(2) constraint dept_pk primary key, dname varchar2(14), loc varchar2(13) ) sqlldr userid=gwm/gwm@fgisdb control=c:\demol.ctl select * from dept; 1 10 Sales Virginia 2 20 Accounting Virginia 3 30 Consulting Virginia 4 40 Finance Virginia
fields terminated by ',' optionally enclose by '"'
fields terminated by ',' optionally enclosed by '"' (deptno,dname,loc) begindata 10,Sales,"Virginia,USA" 20,Accounting,"Va,""USA""" 30,Consulting,Virginia 40,Finance,Virginia select * from dept 1 10 Sales Virginia,USA 2 20 Accounting Va,"USA" 3 30 Consulting Virginia 4 40 Finance Virginia
terminated by whitespace --使用terminated by whitespace load data infile * into table dept replace fields terminated by whitespace (deptno,dname,loc) begindata 10 Sales Virginia select * from dept; 1 10 Sales Virginia --使用terminated by X'09' load data infile * into table dept replace fields terminated by X'09' (deptno,dname,loc) begindata 10 Sales Virginia select * from dept; 1 10
load data infile * into table dept replace fields terminated by X'09' (deptno,dummy1 filler,dname,dummy2 filler,loc) begindata 10 Sales Virginia select * from dept; 1 10 Sales Virginia
load data infile * into table dept replace (deptno position(1:2), dname position(3:16), loc position(17:29) ) begindata 10Accounting Virginia,USA select * from dept; 1 10 Accounting Virginia,USA
alter table dept add entire_line varchar(29);
load data infile * into table dept replace (deptno position(1:2), dname position(3:16), loc position(17:29), entire_line position(1:29) ) begindata 10Accounting Virginia,USA select * from dept; 1 10 Accounting Virginia,USA 10Accounting Virginia,USA
load data infile * into table dept replace (deptno position(1:2), dname position(*:16), loc position(*:29), entire_line position(1:29) ) begindata 10Accounting Virginia,USA
load data infile * into table dept replace (deptno position(1) char(2), dname position(*) char(14), loc position(*) char(13), entire_line position(1) char(29) ) begindata 10Accounting Virginia,USA select * from dept;
alter table dept add last_updated date; load data infile * into table dept replace fields terminated by ',' (deptno, dname, loc, last_updated date 'dd/mm/yyyy' ) begindata 10,Accounting,Virginia,1/5/2000 select * from dept; 1 10 Accounting Virginia 2000-5-1
load data infile * into table dept replace fields terminated by ',' (deptno, dname "upper(:dname)", loc "upper(:loc)", last_updated date 'dd/mm/yyyy' ) begindata 10,Accounting,Virginia,1/5/2000 select * from dept; 1 10 ACCOUNTING VIRGINIA 2000-5-1
load data infile * into table dept replace fields terminated by ',' (deptno, dname "upper(:dname)", loc "upper(:loc)", last_updated date 'dd/mm/yyyy', entire_line ":deptno||:dname||:loc||:last_updated" ) begindata 10,Accounting,Virginia,1/5/2000
load data infile * into table dept replace fields terminated by ',' TRAILING NULLCOLS (deptno, dname "upper(:dname)", loc "upper(:loc)", last_updated date 'dd/mm/yyyy', entire_line ":deptno||:dname||:loc||:last_updated" ) begindata 10,Accounting,Virginia,1/5/2000 select * from dept; 1 10 ACCOUNTING VIRGINIA 10AccountingVirginia1/5/2000 2000-5-1
load data infile * into table dept replace fields terminated by ',' TRAILING NULLCOLS (deptno, dname "upper(:dname)", loc "upper(:loc)", last_updated "case when length(:last_updated)>9 then to_date(:last_updated,'hh24:mi:ss dd/mm/yyyy') when instr(:last_updated,':')>0 then to_date(:last_updated,'hh24:mi:ss') else to_date(:last_updated,'dd/mm/yyyy') end" ) begindata 10,Sales,Virginia,12:03:03 17/10/2005 20,Accounting,Virginia,02:23:54 30,Consulting,Virginia,01:24:00 21/10/2006 40,Finance,Virginia,17/8/2005 alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss'; select * from dept;
alter table dept add comments varchar2(4000); --使用下列来加载文本 load data infile * into table dept replace fields terminated by ',' trailing nullcols (deptno, dname "upper(:dname)", loc "upper(:loc)", comments "replace(:comments,'\\n',chr(10))" --'\\n'换行符用chr(10)这个代替 ) begindata 10,Sales,Virginia,this is the sales\noffice in Virginia
--控制文件 load data infile demo.dat "fix 80" --指定了输入数据文件demo.dat,这个文件中每个记录80字节 into table dept replace fields terminated by ',' trailing nullcols (deptno, dname "upper(:dname)", loc "upper(:loc)", comments ) --数据文件 10,Sales,Virginia,this is the sales\noffice in Virginia 20,,,Sales,Virginia,this is the sales\noffice in Virginia
select * from dept;
--控制文件 load data infile demo.dat "var 3" --表明了前三个字节用于记录每一行的字节数 into table dept replace fields terminated by ',' trailing nullcols (deptno, dname "upper(:dname)", loc "upper(:loc)", comments ) --数据文件 05410,Sales,Virginia,this is the sales office in Virginia
select * from dept;
select utl_raw.cast_to_raw('|'||chr(10)) from dual;--可见在unix上为x'7C0A'
select utl_raw.cast_to_raw('|'||chr(13)||chr(10)) from dual;--为x'7C0D0A'
--控制文件
load data
infile demo.dat "str x'7C0D0A'"
into table dept
replace
fields terminated by ','
trailing nullcols
(deptno,
dname "upper(:dname)",
loc "upper(:loc)",
comments
)
--数据文件
10,Sales,Virginia,this is the sales
office in Virginia|
select * from dept;
--修改表dept truncate table dept; alter table dept drop column comments; alter table dept add comments clob; --数据文件 10,Sales,Virginia,this is the sales office in Virginia| 20,Accounting,Virginia,this is the Accounting office in Virginia| 30,Consuling,Virginia,this is the Consuling office in Virginia| 40,Finance,Virginia,"this is the Finance office in Virginia,it has embedded commas and is much longer than the other comments filed.If you feel the need to add double quotes text in here like this:""you will need to double up those quotes!""to preserve them in the string. This field keeps going for up to 1000000 bytes (because of the control file definition I used) or until we hit the magic and of record marker, the | followed by an end of line - it is right here ->"| --控制文件 load data infile demo.dat "str x'7C0D0A'" into table dept replace fields terminated by ',' optionally enclosed by '"' trailing nullcols (deptno, dname "upper(:dname)", loc "upper(:loc)", comments char(1000000) --sqlldr默认输入的字段都是char(255)。char(1000000)表示允许输入多达1000000个字符 ) select * from dept;
--加载数据的表 create table lob_demo (owner varchar2(255), time_stamp date, filename varchar2(255), data blob) --假设有一目录,其中包含想要加载到数据库中的文件。以下为想要加载文件的owner,time_stamp,文件名及文件本身 load data infile * replace into table lob_demo (owner position(17:25), time_stamp position(44:55) date "Mon DD HH24:MI", filename position(57:100), data lobfile(filename) terminated by EOF ) begindata -rw-r--r-- 1 tkyte tkyte 1220342 jun 17 15:26 classes12.zip select owner,time_stamp,filename,dbms_lob.getlength(data) from lob_demo;
create table image_load( id number, name varchar2(255), image ordsys.ordimage) --首先要了解ordsys.ordimage类型
load data
infile *
into table image_load
replace
fields terminated by ','
(id,
name,
file_name filler,
image column object
(
source column object
(
localdata lobfile(file_name) terminated by EOF
nullif file_name='none'
)
)
)
begindata
1,icons,icons.gif
select * from image_load
--继续编辑加载进来数据的属性 begin for c in (select * from image_load) loop c.image.setproperties;--setproperties是ordsys.ordimage类型提供的方法,处理图像本身,并用适当的值更新对象的其余属性 end loop; end;
create table demo (id int primary key,theclob clob)
create or replace directory dir1 as 'D:\oracle';
SQL> host echo 'hello world!' >d:/oracle/test.txt
declare
l_clob clob;
l_bfile bfile;
begin
insert into demo values (1, empty_clob()) returning theclob into l_clob;
l_bfile := bfilename('DIR1', 'test.txt');
dbms_lob.fileopen(l_bfile);
dbms_lob.loadfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile));
dbms_lob.fileclose(l_bfile);
end;
select dbms_lob.getlength(theclob),theclob from demo;
create or replace directory "dir2" as 'D:\oracle';
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有