SqlLoader怎么使用

2020-07-10 08:04:34易采站长站整理

loc "upper(:loc)",
comments
)
--数据文件
10,Sales,Virginia,this is the sales
office in Virginia|
select * from dept;

6、加载lob数据

1)加载内联的lob数据。这些lob数据通常内嵌有换行符和其他特殊字符


--修改表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;

2)加载外联的lob数据。

    需要把包含有一些文件名的数据文件加载在lob中,而不是让lob数据与结构化数据混在一起。这样就不必使用上述的4种方法之一来避开输入数据中
的内嵌换行符问题,而这种情况在大量的文本或二进制数据中频繁出现。sqlldr称这种额外的数据文件为lobfile。
    sqlldr还可以支持加载结构化数据文件。可以告诉sqlldr如何从另外一个文件解析lob数据,这样就可以加载其中的一部分作为结构化数据中的每一行。
sqlldr称这种外部引用的文件为复杂二级数据文件。

    lobfile数据采用以下某种格式:

    定长字段(从lobfile加载字节100到10000);
    定界字段(以某个字符结束,或用某个字符括起);–最常见,以一个文件结束符(EOF)结束
    长度/值对,这是一个边长字段


--加载数据的表
create table lob_demo
(owner varchar2(255),
time_stamp date,
filename varchar2(255),
data blob)
--假设有一目录,其中包含想要加载到数据库中的文件。以下为想要加载文件的owner,time_stamp,文件名及文件本身
load data
相关文章 大家在看