2017-02-22 27 views
0

我试图使用SQL Loader将客户数据加载到CLOB表中。 由于数据量较大,客户更愿意提供两个文件:主文件 - 带有“主”表数据和辅助文件,带有CLOB。如何使用SQL加载程序从辅助文件映射CLOB数据

我正在寻找正确的输入文件布局和正确的加载语法。 辅助文件是否应该包含一个ID以及SQL Loader如何匹配两个文件中的记录?

我们大约是这个(假设的CLOB被字符串分隔 '< lobend>')的情况:

EMP与列emp_id为简历(CLOB) 。简历是可选的,有时它会为空。

主文件

123, Jane 
567, Mary 
896, Bob 

辅助文件

Resume of Jane<lobend> 
<lobend> 
Resume of Bob<lobend> 

回答

0

假设您的主文件名为primary.dat和您的辅助文件名为secondary.dat。创建一个控制文件,如下所示:

load data 
infile 'primary.dat' 
into table persons 
fields terminated by ',' 
( emp_id char(3) 
    ,ename char(10) 
    ,resume lobfile(constant 'secondary.dat') terminated by "<lobend>\n" 
) 

然后加载:

sqlldr userid=scott/tiger control=loadlob.ctl 

SQL*Loader: Release 12.1.0.2.0 - Production on Wed Feb 22 08:42:13 2017 

Copyright (c) 1982, 2015, Oracle and/or its affiliates. All rights reserved. 

Path used:  Conventional 
Commit point reached - logical record count 3 

Table PERSONS: 
    3 Rows successfully loaded. 

Check the log file: 
    loadlob.log 
for more information about the load. 

检查数据:

EMP_ID ENAME  RESUME 
---------- ---------- ------------------------------ 
     123 Jane  Resume of Jane 
     456 Mary 
     789 Bob  Resume of Bob 
相关问题