暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle SQL加载程序中的CLOB字段选项

askTom 2017-09-07
209

问题描述

嗨,团队,

我们正在将DB2 Z/OS (大型机) 迁移到Oracle 12c r1。我们正在使用DB2中的UNLOAD utility和SQL LOADER在Oracle end中加载。我们面临CLOB归档的问题。
一个表有一个CLOB字段,每一行都卸载了专用的文本文件。数据文件包含clob文件的绝对路径,如show blow:
我们想替换 “第一列是datatype中的CLOB。我们无法处理clob列的控制文件中的替换函数,因为存在不能将SQL字符串用于CLOB列的限制。有没有办法让sql加载器删除/替换“ 同时读取数据文件。

我们不想手动替换数据文件中的 “。

达达文件:

“c:\ 用户 \ abc \ 文件 _ row1.txt” | 值 _ 字段2 | 值 _ 字段3
“c:\ 用户 \ abc \ 文件 _ row2.txt” | 值 _ 字段2 | 值 _ 字段3

预期是:

c:\ 用户 \ abc \ 文件 _ row1.txt | 值 _ 字段2 | 值 _ 字段3
c:\ 用户 \ abc \ 文件 _ row2.txt | 值 _ 字段2 | 值 _ 字段3

示例控制文件:

加载数据
文件 'lob_test.txt'
进入表表 _ 测试
由 “|” 终止的字段
(clob_filename FILLER CHAR(100),
clob_content LOBFILE(clob_filename) 由EOF replace(:clob_filename,'"',') 终止,
col2,
col3
)

谢谢
西伐鲁R

专家解答

也许是这样的:

c:\>cat c:\temp\c.ctl
load data
infile *
replace
into table t
fields terminated by ',' optionally enclosed by '"' trailing nullcols
(
id integer external,
fname filler,
c LOBFILE(fname) TERMINATED BY EOF
)
begindata
1,"c:\temp\demo.out"
2,"c:\temp\load_emoji.sql"

SQL> create table t ( id int, c clob );

Table created.

C:\temp>sqlldr userid=scott/tigercontrol=c:\temp\c.ctl

SQL*Loader: Release 12.2.0.1.0 - Production on Fri Sep 8 15:49:55 2017

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

Path used:      Conventional
Commit point reached - logical record count 1
Commit point reached - logical record count 2

Table T:
  2 Rows successfully loaded.

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

SQL> select id, length(c) from t;

        ID  LENGTH(C)
---------- ----------
         1      17640
         2       1418
复制


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论